1, R
data = open (' Monkey King ', ' r ', encoding = ' utf-8 '). Read ()
Print (data)
#该操作为文件的读操作,
2, W
f = open (' Monkey King ', ' w ', encoding = ' utf-8 ')
F.write (' Hello World ')
F.write (' Karen ') #不换行写入两个, not covering ==>hello Worldkaren
#该操作为文件的写操作, overwrite original content re-edit
f = open (' Monkey King 2 ', ' w ', encoding = ' utf-8 ')
F.write (' Hello World ')
#也可创建新的文件进行写操作
3, F = open (' Monkey King ', ' a ', encoding = ' utf-8 ')
F.append (' Hello World ')
#不影响原内容的情况下继续编辑
4, F.readline () #打印第一行的内容 the cursor after the character that is taken
5, F.readlines () #打印多行
6.
Impor Time;time.sleep (#延时缓冲区)
Open () file
F.fileno () file descriptor
F.tell () cursor position when printing
F.seek (0) Move cursor position
F.close () Close file
F.flush () empty buffer, display to terminal
F.truncate truncation, delete the later content
Python 3.0 file Operation basic Process