TUPLE(元祖)在Python里的作用?
提問人:楊紫紅發(fā)布時(shí)間:2020-11-18
TUPLE(元祖)
元組類似于使用圓括號(hào)的列表,用()進(jìn)行定義,區(qū)別是創(chuàng)建后不能更改
>>> fibs = (0, 1, 1, 2, 3)
>>> print(fibs[3])
>>> fibs[0] = 4
Traceback (most recent call last):
File "<pyshell>", line 1, in <module>
fibs[0] = 4
TypeError: 'tuple' object does not support item assignment
繼續(xù)查找其他問題的答案?
相關(guān)視頻回答
點(diǎn)擊加載更多評(píng)論>>