Python笔记:1.2.4变量与对象_深复制

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bq_cui/article/details/89884975
# -*- coding: utf-8 -*-
"""
Created on Mon May  6 15:58:12 2019

@author: Administrator
"""

from copy import deepcopy

a=[1,2,['str1','str2']]
b=deepcopy(a)
print(a is b)

a.append(3)
print(b)

a[2].append('str3')
print(b)

运行:

False
[1, 2, ['str1', 'str2']]
[1, 2, ['str1', 'str2']]

猜你喜欢

转载自blog.csdn.net/bq_cui/article/details/89884975