我对整数列表有一些问题,它看起来像这样:
它是一个更大的列表的一部分,但是当我尝试逐行扫描并解析它时,我收到以下错误:
ValueError: invalid literal for int() with base 10: '\xef\xbb\xbf85\n'
我的代码如下:
with open("data.csv", "r") as ins:
array = []
for line in ins:
print 'String: ', line
print 'Integer: ', int(line)
如果我尝试使用此代码捕获错误:
with open("data.csv", "r") as ins:
array = []
for line in ins:
print 'String: ', line
try:
print 'Integer: ', int(line)
except:
print 'Non-integer: ', line
我得到了这个输出:
任何人都有线索?