| 查看: 6270 | 回复: 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: ![]() ![]() ![]() 为什么? |
» 猜你喜欢
08工科求调剂290分
已经有11人回复
一志愿985初试354分生物调剂
已经有3人回复
一志愿2110,化学学硕310分,本科重点双非求调剂
已经有13人回复
353求调剂
已经有8人回复
308求调剂
已经有16人回复
334求调剂
已经有14人回复
一志愿0807 数一英一 313 有没有二轮调剂
已经有7人回复
复试调剂,一志愿郑州大学材料与化工289分
已经有14人回复
086000调剂
已经有3人回复
材料类284调剂
已经有23人回复
me_yu
木虫 (正式写手)
- 应助: 26 (小学生)
- 金币: 3383.1
- 散金: 350
- 红花: 7
- 沙发: 1
- 帖子: 900
- 在线: 468.2小时
- 虫号: 2533501
- 注册: 2013-07-05
- 专业: 计算机软件

5楼2017-08-25 11:57:20
2楼2017-06-22 19:16:29
3楼2017-06-26 14:02:55
4楼2017-06-26 14:03:57














回复此楼
