元组的使用 - 知乎 - 知乎专栏
https://zhuanlan.zhihu.com/p/59125946#)直接在后面增加,提示:AttributeError: 'tuple' object has no attribute 'append' # a.append('nihaoa') # print(a) # 直接指定增加到哪个位置 insert 语法变量名.insert(索引,值) #提示:AttributeError: 'tuple' object has no attribute 'insert' # a.insert(1,'zhihu') # print(a) #扩张法,语法变量名1.extend ...
Update tuples in Python (Add, change, remove items in ...
https://note.nkmk.me/en/python-tuple-operation22.07.2020 · Since tuples tuple in Python are immutable sequences, you can not update them. You can not add, change, remove items (elements) in tuples. tuple represent data that you don't need to update, so you should use list rather than tuple if you need to update it. However, if you really need to update tuple, you can convert it to list, update it, and then turn it back into tuple.