操作文件
# coding=utf-8 支持中文
"""
China
Japan
France
England
"""
f = open("record.txt", "a+") # 读写追加
content = f.readline()
print content
content = f.readlines()
print content
f.write('\nGerman')
f.close()
"""
China
Japan
France
England
German
"""
逐行读
# coding=utf-8 支持中文
f = open("record.txt", "r+")
content = f.readline()
while content:
print content
content = f.readline()
f.close()
原文地址:https://www.cnblogs.com/jiqing9006/p/10591529.html
时间: 2024-10-23 20:44:15