replacing items in nested lists python

前端 未结 5 1406
死守一世寂寞
死守一世寂寞 2021-01-16 07:04

I am trying to make a duplicate list of lists and change one element to another within the nested lists of the duplicate list but am having some trouble. How I made the dup

5条回答
  •  梦谈多话
    2021-01-16 07:37

    import copy
    order_1 = copy.deepcopy(order)
    

    Python by default only copies references to mutable values, so changing them in one place results in them being changed everywhere. Creating a deep copy means the two instances are completely independent.

提交回复
热议问题