操作文件

# 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()

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-15
  • 2021-07-13
  • 2021-12-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-25
  • 2021-12-12
  • 2021-12-19
  • 2021-11-26
  • 2022-12-23
  • 2021-09-05
  • 2021-12-15
相关资源
相似解决方案