class E: s='' d=[] def __init__(self): self.dd=[]aa=E()aa.d.append('abc')aa.dd.append('abc')aa.s+='abc'print(aa.d)print(aa.dd)print(aa.s)print('='*20)print(E.d)print(E.s)print('='*20)aa=E()aa.d.append('123')aa.dd.append('123')aa.s+='123'print(aa.d)print(aa.dd)print(aa.s)
输出:
D:\Python37\python.exe D:/study____/PIC/test_import/a/a.py['abc']['abc']abc====================['abc']====================['abc', '123']['123']123Process finished with exit code 0
结论:
可变对象:list dict set
不可变对象:tuple string int float bool