标签:恢复 image 数据 可变对象 http 对象 elf remove bsp
------------恢复内容开始---------
函数可能会修改接收到的任何可变对象。不要使用可变类型的参数作为函数的参数默认值。
class Bus: def __init__(self, passengers=[]): self.passengers = passengers def pick(self, name): self.passengers.append(name) def drop(self, name): self.passengers.remove(name) bus1 = Bus([‘a‘, ‘b‘]) print(bus1.passengers) bus1.pick(‘c‘) bus1.drop(‘a‘) print(bus1.passengers) bus2 = Bus() bus2.pick(‘a‘) print(bus2.passengers) bus3 = Bus() bus3.pick(‘b‘) print(bus3.passengers) print(bus2.passengers) [‘a‘, ‘b‘] [‘b‘, ‘c‘] [‘a‘] [‘a‘, ‘b‘] [‘a‘, ‘b‘]
-
标签:恢复 image 数据 可变对象 http 对象 elf remove bsp
原文地址:https://www.cnblogs.com/liuer-mihou/p/11883516.html