python中元组的赋值操作
文化内容为《流畅的python》阅读整理
python中元组是无法赋值的,那么执行自加操作并赋值时自然就报错了,但是我们却看到元组的值实际已经发生了变化,这是为什么呢?
>>> t = (1, 2, [30, 40])
>>> t[2] += [50, 60]
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: 'tuple' obj
原创
2020-08-03 11:32:18 ·
5788 阅读 ·
0 评论