【发布时间】:2018-12-11 09:08:01
【问题描述】:
这是我在 Python 中的代码,我正在尝试打印该目标状态,但我仍然遇到元组问题:TypeError: 'tuple' object is not callable 谢谢!
goal_state = [[0,1,2],
[3,4,5],
[6,7,8]]
print(goal_state[0])
print(goal_state[1])
print(goal_state[2])
for i in range(0,2):
print(goal_state[i])
runfile('C:/Users/Patrik/Desktop/isi.py', wdir='C:/Users/Patrik/Desktop')
[0, 1, 2]
[3, 4, 5]
[6, 7, 8]
Traceback (most recent call last):
File "<ipython-input-100-16772532c44a>", line 1, in <module>
runfile('C:/Users/Patrik/Desktop/isi.py', wdir='C:/Users/Patrik/Desktop')
File "C:\Users\Patrik\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)
File "C:\Users\Patrik\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Patrik/Desktop/isi.py", line 11, in <module>
for i in range(0,2):
TypeError: 'tuple' object is not callable
【问题讨论】:
-
您没有向我们展示您的所有代码。这段代码有效,这里没有一个元组。
-
我正在使用 Spyder,这就是我所有的代码......我只是想尝试打印它。
-
然后向我们展示整个堆栈跟踪。
-
您现在可以查看,我添加了其余代码