如何在Python中移动小数位?
发布于 2021-01-29 14:56:57
我目前正在使用以下内容两次计算差异。出局非常快,因此无论如何我都不需要显示小时和分钟,它们仅是0.00。我实际上如何在Python中移动小数位?
def time_deltas(infile):
entries = (line.split() for line in open(INFILE, "r"))
ts = {}
for e in entries:
if " ".join(e[2:5]) == "OuchMsg out: [O]":
ts[e[8]] = e[0]
elif " ".join(e[2:5]) == "OuchMsg in: [A]":
in_ts, ref_id = e[0], e[7]
out_ts = ts.pop(ref_id, None)
yield (float(out_ts),ref_id[1:-1], "%.10f"%(float(in_ts) - float(out_ts)))
INFILE = 'C:/Users/kdalton/Documents/Minifile.txt'
print list(time_deltas(INFILE))
关注者
0
被浏览
73