import copy啥意思
时间: 2023-08-25 20:05:39 浏览: 103
import copy is a Python module that provides functions for creating copies of objects.
The term "copy" refers to creating a new object that has the same values as another object. This is important because it allows you to modify one object without affecting the other.
For example, if you have a list of numbers and you want to modify it without changing the original list, you can create a copy of the list using the copy module.
Here is an example:
```python
import copy
original_list = [1, 2, 3]
new_list = copy.copy(original_list)
new_list[0] = 4
print(original_list) # Output: [1, 2, 3]
print(new_list) # Output: [4, 2, 3]
```
As you can see, modifying the new_list did not affect the original_list because they are two separate objects.