| 查看: 6225 | 回复: 5 | ||
| 当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖 | ||
[求助]
新手导入csv过程中总是出现python could not convert string to float 已有1人参与
|
||
|
程序: image_path = r'C:\Users\abc\Documents\csv_result\cracking\41.csv' with open(image_path,'r') as image_file: image_string = image_file.read() image_string = image_string.replace(' ','').replace('\n',',').replace('\t','') print(image_string) image_data = image_string.split(',') print(image_data) image_data_values = [float(x) for x in image_data] print (image_string) 前两个结果1 -11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.26,-11.2 结果2 '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', '-11.26', 然后报错 ValueError Traceback (most recent call last) <ipython-input-27-225cd40ddc4d> in <module>() 6 image_data = image_string.split(',') 7 print(image_data) ----> 8 image_data_values = [float(x) for x in image_data] 9 print (image_string) <ipython-input-27-225cd40ddc4d> in <listcomp>(.0) 6 image_data = image_string.split(',') 7 print(image_data) ----> 8 image_data_values = [float(x) for x in image_data] 9 print (image_string) ValueError: could not convert string to float: ![]() ![]() ![]() 为什么? |
» 猜你喜欢
346求调剂[0856]
已经有7人回复
一志愿山大07化学 332分 四六级已过 本科山东双非 求调剂!
已经有3人回复
310求调剂
已经有3人回复
机械专硕299求调剂至材料
已经有4人回复
070300化学319求调剂
已经有7人回复
08工科 320总分 求调剂
已经有6人回复
一志愿天津大学化学工艺专业(081702)315分求调剂
已经有12人回复
307求调剂
已经有3人回复
265求调剂
已经有3人回复
301求调剂
已经有10人回复
6楼2017-10-24 20:12:23
2楼2017-06-22 19:16:29
3楼2017-06-26 14:02:55
4楼2017-06-26 14:03:57














回复此楼
