Mode can be done if the file does not exist whether overwrite
R can only read the newspaper wrong-
r+ readable and writable error is
W can only write Create is
w+ Readable writable Create Yes
A can only write create no, append write
A + readable writable create no, append write
1. Read-only mode (r) an existing file:
Def file_operation ():
With open ('/wzd/test.txt ', mode= ' R ') as F:
# f.write (' abc ')
R = F.readlines ()
Print R
print '---done---'
File_operation ()
2. Read-only mode (r) a nonexistent file:
Def file_operation ():
With open ('/wzd/test001.txt ', mode= ' R ') as F:
# f.write (' abc ')
R = F.readlines ()
Print R
print '---done---'
File_operation ()
3. Read-only mode to write files:
Def file_operation ():
With open ('/wzd/test.txt ', mode= ' R ') as F:
F.write (' abc ')
R = F.readlines ()
Print R
print '---done---'
File_operation ()
Python file read/write mode r,r+,w,w+,a,a+ differences (with code example)