2018-10-23
閱讀量:
980
python錯(cuò)誤解析(十七)
代碼如下:
>>> t = (1,2)
>>> t.append(3)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'append'
>>> t.remove(2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'remove'
>>> t.pop()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'pop'
【錯(cuò)誤分析】屬性錯(cuò)誤,歸根到底在于元祖是不可變類型,所以沒有這幾種方法.






評論(0)


暫無數(shù)據(jù)
CDA考試動態(tài)
CDA報(bào)考指南
推薦帖子
0條評論
0條評論
0條評論