案例1:
async
输出:
def good_append(new_item, a_list=None):
if a_list is None:
a_list = []
a_list.append(new_item)
print a_list, id(a_list)
return a_list
if __name__ == '__main__':
one = good_append("one")
two = good_append("two")
案例2:
['one'] 45267144
['two'] 45506312
输出:
def good_append(new_item, a_list=None):
if a_list is None:
a_list = []
a_list.append(new_item)
print a_list, id(a_list)
为什么在案例2中获得相同的['one'] 44611784
['two'] 44611784