Python 创建具有特殊类型的列表-Spyder error“;名称';脚本';“未定义”;

Python 创建具有特殊类型的列表-Spyder error“;名称';脚本';“未定义”;,python,Python,我想在脚本0中打印以测试代码,因此我编写了脚本[0][4][2]。但系统告诉我 name 'script' is not defined 我不能这样定义它吗 script[0] = ['A','A',['A'],['A'],['A','5','>'],'A'] script[1] = [2,3,[4,4],[2,3],['V','232','='],'G'] print(script[0][4][2]) 将列表定义为[],并使用追加将元素添加到列表中: script = [] scr

我想在脚本0中打印
以测试代码,因此我编写了
脚本[0][4][2]
。但系统告诉我

name 'script' is not defined
我不能这样定义它吗

script[0] = ['A','A',['A'],['A'],['A','5','>'],'A']
script[1] = [2,3,[4,4],[2,3],['V','232','='],'G']
print(script[0][4][2])

将列表定义为
[]
,并使用
追加
将元素添加到列表中:

script = []

script.append(['A','A',['A'],['A'],['A','5','>'],'A'])
script.append([2,3,[4,4],[2,3],['V','232','='],'G'])

print(script[0][4][2])
# >

我稍微修改了您的代码:

script = [['A','A',['A'],['A'],['A','5','>'],'A'], [2,3,[4,4],[2,3],['V','232','='],'G']]

print(script[0][4][2]) #returns >
它是有效的。从下一次开始,尝试使用@Austin:)建议的“append”成员