How to deep copy a list?

前端 未结 8 1469
旧巷少年郎
旧巷少年郎 2020-11-22 03:07

I have some problem with a List copy:

So After I got E0 from \'get_edge\', I make a copy of E0 by calling \'E0_copy =

8条回答
  •  温柔的废话
    2020-11-22 03:34

    This is more pythonic

    my_list = [0, 1, 2, 3, 4, 5]  # some list
    my_list_copy = list(my_list)  # my_list_copy and my_list does not share reference now.
    

    NOTE: This is not safe with a list of referenced objects

提交回复
热议问题