【发布时间】:2018-08-18 18:10:07
【问题描述】:
我有以下代码
text_file = open("up2017.txt", "r")
amount=[]
for line in text_file:
fields = line.strip().split(" ")
amount.append(fields[-1])
list(map(float,amount))
我收到以下错误
ValueError: 无法将字符串转换为浮点数:'50.000,00'
文本文件看起来像
13.10 Ovf 12.10 50.000,00 50.000,00
30.10 Bgs 30.10 12.000,00 62.000,00
30.11 Bgs 30.11 12.000,00 74.000,00
15.12 Bgs 15.12 53.528,36 127.528,36
30.12 Bgs 30.12 12.000,00 139.528,36
【问题讨论】:
标签: python string python-3.x dictionary