我有以下python脚本,它导入.json文件并通过rhino / grasshopper绘制它们。当我链接文件路径时它似乎工作正常,直到我点击17个文件,一旦我尝试输入第18个及以后我得到以下消息“1.解决方案异常:list.index(项目):项目不在列表中”
有人有什么想法吗?在编码等方面我真的迷失了...... 谢谢!
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)