import?os
names=[]
def?searchAll(filePath=os.getcwd()):
#x={'old':'dummy'}?把这里移到for?里面
for?i?in?range(0,2):
x={'old':'dummy'}#移到这里
print?'0x01',names
x['old']=i
print?'0x02',names
names.append(x)
print?'0x03',names
if?__name__?==?'__main__':
searchAll()
#解释一哈?因为names=[{'old':?0}]的时候?x={'old':?0},这个时候循环到1?这个时候你改变
x['old']=1?那么names=[{'old':?0}]里面的?{'old':?0}==》{'old':?1}?,
names里面的{'old':?0}?和x?指向同一内存地址?一边都变