我有以下 python 脚本,它导入 .json 文件并通过 rhino/grasshopper 绘制它们。当我也链接文件路径时,它似乎工作正常,直到我点击 17 个文件,一旦我尝试输入第 18 个及以后的文件,我收到以下消息“1。解决方案异常:list.index(item):item not in list”
有人有想法么?在编码等方面我真的很迷茫......谢谢!
import json if FilePath: # JSON file to read file = open(FilePath) # Load the data data = json.load(file) import pprint pp = pprint.PrettyPrinter(indent=4) a=[]; b=[]; L = list(data[0]['segments']) y = len(L) print y pp.pprint(L) for x in range (0,1): M = list(L[x]['activities']) q = len(M) print q for w in range (0, q): N = list(M[w]['trackPoints']) r = len(N) print r for final in range (0,r): c = N[final]['lat'] d = N[final]['lon'] a.append(c) b.append(d) for x in range (2,2): M = list(L[x]['activities']) q = len(M) print q for w in range (0, q): N = list(M[w]['trackPoints']) r = len(N) print r for final in range (0,r): c = N[final]['lat'] d = N[final]['lon'] a.append(c) b.append(d) for x in range (3,5): M = list(L[x]['activities']) q = len(M) print q for w in range (0, q): N = list(M[w]['trackPoints']) r = len(N) print r for final in range (0,r): c = N[final]['lat'] d = N[final]['lon'] a.append(c) b.append(d) for x in range (6,7): M = list(L[x]['activities']) q = len(M) print q for w in range (0, q): N = list(M[w]['trackPoints']) r = len(N) print r for final in range (0,r): c = N[final]['lat'] d = N[final]['lon'] a.append(c) b.append(d) for x in range (8,11): M = list(L[x]['activities']) q = len(M) print q for w in range (0, q): N = list(M[w]['trackPoints']) r = len(N) print r for final in range (0,r): c = N[final]['lat'] d = N[final]['lon'] a.append(c) b.append(d) for x in range (12,12): M = list(L[x]['activities']) q = len(M) print q for w in range (0, q): N = list(M[w]['trackPoints']) r = len(N) print r for final in range (0,r): c = N[final]['lat'] d = N[final]['lon'] a.append(c) b.append(d)