|
发表于 2020-5-17 21:22:54
|
显示全部楼层
- import os
- txt_file = 'trainloss.txt'
- try:
- os.remove(txt_file)
- except:
- print('不存在改文件')
- with open(txt_file,'a') as f:
- f.write(str(1.01)+'\n')
- f.write(str(10.5)+'\n')
- f.write(str(5)+'\n')
- f.write(str(6.2)+'\n')
- f.close();
- with open(txt_file,'a') as f:
- f.write(str(1.01)+'\n')
- f.write(str(10.5)+'\n')
- f.write(str(5)+'\n')
- f.write(str(6.2)+'\n')
- f.close();
- txt_file = 'trainloss.txt'
- with open(txt_file, 'r') as f:
- indexs1=f.readline()
- indexs2=f.readlines()
- index1 = float( indexs1 )
- # print(index1)
- index2 = str( indexs2 ).split('.')[0]
复制代码 |
|