这个不是深拷贝,还是引用
aiscript_original =aiscript.copy()
原因分析
No, this is not a deep copy. The .copy()
method on dictionaries creates a shallow copy. This means:
- Only the top-level dictionary structure is copied
- The values inside (like lists and nested dictionaries) are still references to the same objects
- If you modify nested data in
ai_script
after this line, those changes will also affectai_script_original
For a true deep copy, you would need to use:
import copy
aim_script_original = copy.deepcopy(aim_script)
The comment mentioning “深拷贝” (deep copy) is misleading since the implementation is actually a shallow copy.