我发现可以从一个实例更改所有实例的变量。
class Example:
s = 's'
lst = []
a = Example()
a.s = 'z' # change instance variables
a.lst.append(1)
b = Example()
print(b.s) # 's', the class variable of type 'Str' did not changed
print(b.lst) # '[1]', but class variable of type 'List' changed
a.lst.append(7)
print(b.lst) # '[1, 7]', values of all existing instances changing by instance variable
我为“列表”类型找到了它,但是其他类型也可能存在这样的安全问题/功能? 还是我感到困惑?