python3 TypeError: 'type' object is not subscriptable

原本以为是类型错误,后来仔细一看,才知道是列表名称写错了。汗,改为list1[2],就好了

list1 = ['Google', 'Runoob', 1997, 2000];
list2 = [1, 2, 3, 4, 5 ];
list3 = ["a", "b", "c", "d"];


print ("第三个元素为 : ", list[2]);
list[2] = 2001;
print ("更新后的第三个元素为 : ", list[2]);

控制台:
    print ("第三个元素为 : ", list[2]);
TypeError: 'type' object is not subscriptable

这类问题的解决思路,找到对应位置,进行调试,一般是空值原因,看看你属于哪种?

猜你喜欢

转载自blog.csdn.net/qq_39308071/article/details/82379191
今日推荐