python中,tuple裏的list中的元素爲何能夠變,tuple到底可不可變?

衆所周知,tuple與list的區別就是tuple是不可變的,是爲了讓程序更安全,tuple能夠看成dict的key可是list不行。但tuple並非徹底不可變的,以下所示,tuple中的list的元素就是能夠修改的。python >>> a = 1 >>> b = 2 >>> c = [3,4,5] >>> d = (a,b,c) >>> d (1, 2, [3, 4, 5]) >>> d[2]
相關文章
相關標籤/搜索