| 查看: 6227 | 回复: 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: ![]() ![]() ![]() 为什么? |
» 猜你喜欢
本人考085602 化学工程 专硕
已经有23人回复
求调剂院校信息
已经有4人回复
085600材料与化工306
已经有4人回复
286求调剂
已经有10人回复
328求调剂,英语六级551,有科研经历
已经有9人回复
一志愿北京化工大学070300 学硕336求调剂
已经有4人回复
286分人工智能专业请求调剂愿意跨考!
已经有8人回复
资源与环境 调剂申请(333分)
已经有5人回复
280求调剂
已经有12人回复
269专硕求调剂
已经有5人回复
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














回复此楼

10