python deep and shallow copy

1. For strings (str) and numbers

Deep and shallow copy and assignment, the address is the same

2. For lists, dictionaries, and tuples

Shallow copy: Only the outermost layer is copied, and the rest share one copy

Deep copy: copy all but the innermost layer (strings and numbers)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324522271&siteId=291194637