Does Python have an immutable list?

后端 未结 6 548
遥遥无期
遥遥无期 2020-12-04 18:31

Does python have immutable lists?

Suppose I wish to have the functionality of an ordered collection of elements, but which I want to guarantee will not change, how c

6条回答
  •  旧巷少年郎
    2020-12-04 19:09

    But if there is a tuple of arrays and tuples, then the array inside a tuple can be modified.

    >>> a
    ([1, 2, 3], (4, 5, 6))
    
    >>> a[0][0] = 'one'
    
    >>> a
    (['one', 2, 3], (4, 5, 6))
    

提交回复
热议问题