0
Why I can't read the file
m = open('hi',"w") m.write('hello') m.close g = open('hi', "r") a = g.read() print(a)
4 odpowiedzi
+ 4
You're not closing file <m>, remember to call a method, we need to (at least) put empty parentheses after method name - when the method has no parameter.
m.close() # you forgot the () - parentheses.
Don't forget to close file <g> correctly.
+ 1
Thanks you it work . But one thing I don't understand in file mode "w+" I can write on it but I can't read on that mode
+ 1
Try to read this page, hopefully it helps clarify your doubt
https://realpython.com/read-write-files-JUMP_LINK__&&__python__&&__JUMP_LINK/
0
import logging
logging.basicConfig(level=logging.debug,filename ='hi.txt', filemode= 'w',format= '%(asctime)s')
logging.debug('from debug' )