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

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

@author: Administrator
"""
from copy import copy

a=[1,2,['str1','str2']]
b=copy(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', 'str3']]

猜你喜欢

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