标签:style blog color io ar 问题 div cti log
list 的拷贝问题:
1 >>> a 2 [1, 2] 3 >>> b=a[:] 4 >>> b 5 [1, 2] 6 >>> b[0]=20 7 >>> b 8 [20, 2] 9 >>> a 10 [1, 2]
2,
1 import copy 2 >>> c=copy.copy(a) 3 >>> c 4 [1, 2] 5 >>> c[1]=30 6 >>> c 7 [1, 30] 8 >>> a 9 [1, 2] 10 >>> b 11 [20, 2]
dictionary:
1 >>> a=[(‘he‘,1),(‘wo‘,‘jia‘)]
2 >>> p=dict(a)
3 >>> p
4 {‘wo‘: ‘jia‘, ‘he‘: 1}
5 >>> b=p.copy()
6 >>> b
7 {‘wo‘: ‘jia‘, ‘he‘: 1}
8 >>> b[‘wo‘]=‘ja‘
9 >>> b
10 {‘wo‘: ‘ja‘, ‘he‘: 1}
11 >>> p
12 {‘wo‘: ‘jia‘, ‘he‘: 1}
标签:style blog color io ar 问题 div cti log
原文地址:http://www.cnblogs.com/fkissx/p/3942413.html