1. 程式人生 > >python復習

python復習

層次 復習 not in 運算符 -- pytho not pri 深淺拷貝

身份運算符:is , is not
成員運算符:in , not in
1.深淺拷貝
s = [‘nihao ‘, 2]
s1 = s.copy()
print(s1)
print(s,s1)
<1>淺拷貝(只會copy第一層次)
b=a[:] #b=a.copy()
-------------------------------
s = [[1, 2], ‘nihao‘, 2]
d = s
print(id(s))
print(id(d))
#32285040
#32285040
-------------------------------
s = [[1, 2], ‘nihao‘, 2]
d = s.copy()
print(id(s))
print(id(d))
#6726000
#6797272
<2>s深拷貝(克隆一份)

python復習