- 博客(6)
- 收藏
- 关注
原创 python中定义类中cls和self的区别
a = A()a.foo1("world") # 输出hello worldA.foo1("world") # 输出hello worldclass A:a = 'a'print(A.a)print(A.foo2("xx")) #报错:unbound method foo2() must be called with A instance as first argument (got str instance instead)print(A.a)
2024-05-25 11:08:59 261
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人