IndexError: list assignment index out of range的解决方法
L2 = []c = int(input("请输入商品编号:"))L2[a] = L1[c]描述:当L2为一个空列表,直接按索引值向其中添加东西时,会报错,因为空的列表不能直接指定其位置解决办法:L2 =[]c = int(input("请输入商品编号:"))L2.append(1) L2[a] = L1[c]每次赋
原创
2019-03-17 09:56:29 ·
77600 阅读 ·
3 评论