Message from Python discussions

November 2018

— Who know any website that has list of python gui problems? I want to practice

— 

Hi Guys, I have a question if I have the following code:
f = open("test.txt","r") #opens file with name of "test.txt"
print(f.read(1))
print(f.read())
f.close()

And I would like to read txt files and send the message (text inside the file) to the user in Telegram.
bot.send_message(chat_id=chat_id, text= ...something...
)

— Anyone have an idea?

— Content = f.read()
bot.send_message(chat_id=chat_id, text = content
)

doesn't this work?

— No not really

— I usually use f.close() when I open file in writing mode)

— Content = strVar()
content = f.read()
bot.send_message(chat_id=chat_id, text = content
)

how about this

Message permanent page

— Language:

py3


Source:
strVar()


Errors:
Traceback (most recent call last):
File "source_file.py", line 1, in <module>
strVar()
NameError: name 'strVar' is not defined

Message permanent page

— It is StringVar(), i used it for tkinter

— Thank you will try that tonight

— Don't, it has no effect whatsoever

— What you need is a) use with, and b) use io.open with an encoding