【发布时间】:2015-03-18 18:41:43
【问题描述】:
如何将带有此字符串“70”(带有撇号)的字符串转换为长字符串
代码:
gap = long(x.film_index)- long (expected_film)
错误:ValueError: invalid literal for long() with base 10: '"70"'
【问题讨论】:
-
你试过只删除帖子吗?
long(x.film_index.strip('"'))? -
另请注意
long在 3.x 中消失了,在 2.x 或 3.x 中使用int并没有什么害处,因为在 2.x 中它会自动转换为long需要的地方。 -
同样的错误:ValueError: int() 以 10 为底的无效文字:'"70"'
-
仍然没有帮助 gap = (x.film_index.strip('"'))- (expected_film.strip('"')) AttributeError: 'int' object has no attribute 'strip'
-
那么其中一个已经是 int 而不是字符串...
type(x.film_index), type(expected_film)向您展示了什么?
标签: python python-2.7