读取每一行的另一种方式:
with open('game.txt') as file:
l = file.readlines()
for line in l:
print(line)
写入新的数据:
#覆盖模式 'w'代表写入-覆盖
with open('game.txt', 'w') as file:
file.write('abc')
#附加模式 'a'代表写入-附加
with open('game.txt', 'a') as file:
file.write('\nefg')
#只读的话,后面加'r'