Python无法解析我的整数列表

时间:2017-03-01 13:35:03

标签: python

我对整数列表有一些问题,它看起来像这样:

enter image description here

它是一个更大的列表的一部分,但是当我尝试逐行扫描并解析它时,我收到以下错误:

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

我得到了这个输出:

enter image description here

任何人都有线索?

0 个答案:

没有答案