标签:style blog color sp div on log bs as
1.创建一个列表
1 >>> a = [1,2,"hacker","geek",4,5,6] 2 >>> a 3 [1, 2, ‘hacker‘, ‘geek‘, 4, 5, 6]
2.赋值操作
1 >>> a = [1,2,"hacker","geek",4,5,6] 2 >>> a 3 [1, 2, ‘hacker‘, ‘geek‘, 4, 5, 6] 4 >>> a[1]="hello world" #下标是以0开始,修改下标 5 >>> a 6 [1, ‘hello world‘, ‘hacker‘, ‘geek‘, 4, 5, 6]
3.a和b是一个内存
1 >>> b = a 2 >>> b 3 [1, ‘hello world‘, ‘hacker‘, ‘geek‘, 4, 5, 6]
a和c只是副本的关系
1 >>> c = a[:] 2 >>> c 3 [1, ‘hello world‘, ‘hacker‘, ‘geek‘, 4, 5, 6]
如何验证:
可以看出,b的改变的同时,a也改变,但是c没有改变
1 >>> b[1]=10 2 >>> b 3 [1, 10, ‘hacker‘, ‘geek‘, 4, 5, 6] 4 >>> a 5 [1, 10, ‘hacker‘, ‘geek‘, 4, 5, 6] 6 >>> c 7 [1, ‘hello world‘, ‘hacker‘, ‘geek‘, 4, 5, 6]
标签:style blog color sp div on log bs as
原文地址:http://www.cnblogs.com/sxmcACM/p/4099456.html