- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个脚本可以解析来自 csv 文件的数据。下面一行给我带来了问题:
countData.append([timeStamp,int(my_csv[row][5])])
它给了我以下错误:
ValueError: invalid literal for int() with base 10: '808.666666666667'
csv文件的行如下:
2013-06-12 15:09:00,svcName,0,0,10,808.666666666667
我试过在 python 提示符下运行 int(808.666666666667)
并且运行正常。
最佳答案
来自 int
的帮助:
int(x, base=10) -> int or long
If x is not a number or if base is given, then x must be a string or Unicode object representing an integer literal in the given base.
因此,对于任何 base
,'808.666666666667'
是 int
的无效文字,使用:
>>> int(float('808.666666666667' ))
808
int(808.666666666667)
运行良好,因为您传递的是 float ,而不是字符串文字。
关于Python:以 10 为底的 int() 的无效文字: '808.666666666667',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17557870/
我有一些按钮总是 float 在浏览器窗口的底 Angular 。 后退 按钮位于正确的位置,但下一步 按钮不会正确 float 。 #footerback { width: 107px;
有谁知道如何在传统 java 中使用此公式计算三角形的面积而不更改或添加公式中的任何内容? 面积 = 1/2*底*高 如果我像这样修改公式: 面积=1.0f/2*baseheigh 或 1/2.0fb
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关于您编写的代码问题的问题必须在问题本身中描述具体问题 — 并且包括有效代码 以重现它。参见 SS
我正在使用 jQuery mobile 并有一个 div,我只希望底部的 2 个 Angular 具有 flex 的外观。 根据我的阅读,我明白我应该使用: ui-corner-bl 和 ui-cor
我是一名优秀的程序员,十分优秀!