Python - 几个注意的要点

使用setuptools对包进行安装

单个项目中对上层的包的调用是不好的

self和cls

  • cls是class的缩写,可以用来调用类内部的静态方法
  • self就像是C中的this

使用setattr和getattr来对对象进行赋值

pythonclass A:
    def __init__(self):
        self.a = 'a'

a = A() 
setattr(a, 'a', 'b')

>>> a.a
'b'

静态的方法

@staticmethod

你可能感兴趣的:(python)