写文件
文章平均质量分 69
妙舞汉宫人
这个作者很懒,什么都没留下…
展开
-
Python 用文件保存游戏(1)
from random import randint #读取文件中的成绩数据 f=open('game.txt') score=f.read().split() #分别存入变量中 game_times=int(score[0]) min_times=int(score[1]) total_times=int(score[2]) #计算游戏的平均轮数,注意浮点数和避免除零错误 if game_转载 2016-07-22 15:28:08 · 608 阅读 · 0 评论 -
Python 用文件保存游戏(2)
from random import randint #读取文件中的成绩数据 f=open('game.txt')#注意文件名要正确 score=f.read().split() f.close() #分别存入变量中 game_times=int(score[0]) min_times=int(score[1]) total_times=int(score[2]) #计算游戏的平均轮数,转载 2016-07-22 15:25:25 · 1159 阅读 · 0 评论 -
Python 写文件
f=file('data.txt') #从data中读内容,保存至data1中 data=f.read() print data out=open('data1.txt','w') out.write(data) out.close() 结果: I love you! hahaha biubiubiu!!! (在文件夹中创建了名为data1的txt文件,里面的内转载 2016-07-20 13:08:40 · 256 阅读 · 0 评论