码迷,mamicode.com
首页 > 其他好文 > 详细

集合里面嵌套列表,会报错却是可变的

时间:2018-08-24 22:52:46      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:object   obj   mod   +=   type   port   报错   recent   error:   

>>> s = (1,2,3,[2,3])
>>> s
(1, 2, 3, [2, 3])
>>> s[3] + [5,6]
[2, 3, 5, 6]
>>> s[3] += [5,6]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ‘tuple‘ object does not support item assignment
>>> s
(1, 2, 3, [2, 3, 5, 6])

集合里面嵌套列表,会报错却是可变的

标签:object   obj   mod   +=   type   port   报错   recent   error:   

原文地址:https://www.cnblogs.com/zengsf/p/9532228.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!