为什么python的list.index()方法会多出个空格?

get = [11423973, 6438805, 58, 4997153, 756111, 354301, 155996, 114514, 45806, 41003, 37388, 24570, 19884, 19500, 16850, 16542, 15137, 11770, 10000, 10000, 8661, 7189, 6441, 5887, 5742, 4914, 3868]

uid = 100000
with open('宝石.json', 'r', encoding='utf-8')as baoshi_read:
        read_baoshi = json.loads(baoshi_read.read())
with open('存款.json', 'r', encoding='utf-8')as ck_read:
        read_cunkuan = json.loads(ck_read.read())

count_idx_num = read_baoshi[str(uid)] + read_cunkuan[str(uid)]
found_b = get.index(count_idx_num)

我可以保证在读取json和在计算没有问题,但就是到了list.index这里无缘无故会在count得到的值前面加个空格(无论有没有定义为Int)然后就报ValueError错误,想问问有什么解决方法解决。

你可能对ValueError有什么误解,这个报错不是说你的数字里面有个空格,而是列表get里没有11433973这个数字。

如果对列表里没有的数字使用index方法,会抛出一个valueError的错误。

count_idx_num = read_baoshi[str(uid)] + read_cunkuan[str(uid)] 

这句返回的结果是一个值, 这个值在get这个列表中不存在