7886人加入学习
(35人评价)
Python零基础入门学习2020最新版(SiKi)

使用Python3.8 于2019/10/20开始录制

价格 免费

读取每一行的另一种方式:

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'

 

[展开全文]