清空 python list
清空python list,使用del與真接給定[]的分別
a = [1,2,3]
b = a
a=[]
print a
print b
得
a = []
b = [1,2,3]
######################################
a = [1,2,3]
b = a
del a[:]
print a
print b
得
a = []
b = []
a = [1,2,3]
b = a
a=[]
print a
print b
得
a = []
b = [1,2,3]
######################################
a = [1,2,3]
b = a
del a[:]
print a
print b
得
a = []
b = []
留言
張貼留言