这是我在Python中的代码,我正在尝试打印goal_state,但是仍然有元组的问题:TypeError:'tuple'对象不可调用 谢谢!
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
答案 0 :(得分:0)
似乎您已为变量range
分配了一些元组值。使用del range
进行重置,然后range(0, 2)
会正确评估。