如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# coding=utf-8
# 用来处理数字,大于上限的数字置零
f = open ( "/home/chuwei/桌面/trainA/loss/d_losses.txt" )
line = f.readline()
k = open ( "/home/chuwei/桌面/trainA/loss/d_losses_1.txt" , "a" )
while line:
# print("line:",(line))
if ( float (line) > 0.5 ):
print ( "line:" , (line))
line = 0.0
line = str (line)
k.write(line)
k.write( "\n" )
else :
k.write(line)
line = f.readline()
f.close()
|
以上这篇python 处理数字,把大于上限的数字置零实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/qq_34638161/article/details/82663627