0
How can I open a file with python shell on windows 7 ?
2 Respuestas
+ 2
file = open("C:\\Documents\\myPython.py",r)
#notice the \\. It is the escape sequence to print '\'.
or
file = open(r"C:\Documents\myPython.py", r)
#no need for 2x'\' when the r comes before the path. The r stands for raw data.
#don't forget to close your file with 'file.close()'
or
with open(r"C:\Documents\myPython.py", r) as file:
print (file.read()) #indented
#this way it closes the file automatically.
r is reading mode
r+ gives you the ability to write
w is write mode
w+ gives you the ability to read
a gives you the ability to append content to the file...
Consult the python tutorial for more information regarding the modes.
0
i use the code , it didn't work!
do you think the problem is with the way I save the file?