文件操作可以读取全部或者读取一行一行,也可以执行不同文件之间内容复制之类的
file = open("readme.txt")
text = file.read()
print(text)
file.close()
file = open("readme.txt")
while True:
text = file.readline()
if not text:
break
print(text)
file.close()
file_read = open("README")
file_write = open("README[附件]", "w")
text = file_read.read()
file_write.write(text)
file_read.close()
file_write.close()
file_read = open("README")
file_write = open("README[附件]", "w")
while True:
text = file_read.readline()
if not text:
break;
file_write.write(text)
file_read.close()
file_write.close()