【发布时间】:2020-09-29 18:57:29
【问题描述】:
我在非常幼稚的 python 代码中收到错误:
mylist = ("a" , "b" , "c")
mylist
mylist
('a', 'b', 'c')
mylist2 =(1, 2, 3,4,5)
mylist2
(1, 2, 3, 4, 5)
mylist(0)
mylist2(0)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-11-8dec3b0af63c> in <module>
----> 1 mylist(0)
TypeError: 'tuple' object is not callable
mylist2(0)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-12-a2be157acb8f> in <module>
----> 1 mylist2(0)
TypeError: 'tuple' object is not callable
【问题讨论】:
-
你想让
mylist[0]索引元组并获取它的第一项吗? -
查看教程Tuples and sequences。
-
我认为答案是通读一些基础教程。通过示例学习比在这里提问更快。
-
这能回答你的问题吗? 'Tuple' object is not callable - Python
-
这能回答你的问题吗? What exactly are tuples in Python?
标签: python indexing tuples jupyter