How to use the function of copy module in python
This article mainly shows you "how to use the function of copy module in python", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn how to use the function of copy module in python "this article.
1. The copy.copy () function can be used to copy variable values such as lists or dictionaries. The copied list and the original list are two separate lists.
Import copyorigin = [1Jing 2 Jue 3] new = copy.copy (origin) new [0] = 0print ("origin =", origin) print ("new =", new)
2. If there is a list in the list you want to copy, use the deepcopy () function to copy it completely.
Import copyorigin = [1python 2jin3], new = copy.deepcopy (origin) # use deep copynew [0] [0] = 0print ("origin =", origin) print ("new =", new) all the contents of this article "how to use the functions of copy module in python", thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!