I ve been learning about files in python 3.9.6 when this happen:
- I open a file using the open command
- Write to a file
- printed the text with file.read()
- the file.read() type is str
- print (file.read()) will return nothing .
I am using python 3.9.6 , pycharm community and python IDLE gave the same result, and the problem is , i assumed that if we passed th file.read() which is a string , the print command will be able to actually print it .
>>>file1 = open('t.txt', 'a')
>>>file1.write('hahah')
>>>file1.close()
>>>file1 = open('t.txt', 'r')
>>>file1.read()
'hahah'
>>>print(file1.read())
>>>type(file1.read())
<class 'str'>