Python
- 37 ответов
- 0 вопросов
41
Вклад в тег
a = b[:]
# или
a = b.copy()
b = [1, 2]
>>> b.append(b)
>>> b
[1, 2, [...]]
>>> id(b)
139920848119752
>>> id(b[2])
139920848119752
>>> a = b[:]
>>> a
[1, 2, [1, 2, [...]]]
>>> id(a)
139920848120456
>>> id(a[2])
139920848119752
from copy import deepcopy
>>> a = deepcopy(b)
>>> a
[1, 2, [...]]
>>> id(a)
139920847744840
>>> id(a[2])
139920847744840