| 查看: 6181 | 回复: 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: ![]() ![]() ![]() 为什么? |
» 猜你喜欢
有没有人能给点建议
已经有4人回复
假如你的研究生提出不合理要求
已经有12人回复
实验室接单子
已经有7人回复
全日制(定向)博士
已经有5人回复
萌生出自己或许不适合搞科研的想法,现在跑or等等看?
已经有4人回复
Materials Today Chemistry审稿周期
已经有4人回复
参与限项
已经有3人回复
对氯苯硼酸纯化
已经有3人回复
所感
已经有4人回复
要不要辞职读博?
已经有7人回复
me_yu
木虫 (正式写手)
- 应助: 26 (小学生)
- 金币: 3369.5
- 散金: 350
- 红花: 7
- 沙发: 1
- 帖子: 895
- 在线: 468.1小时
- 虫号: 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













回复此楼
