jzztf / wiki

wiki
https://jzztf.github.io
Other
1 stars 0 forks source link

py-class-minimalclass #22

Open jzztf opened 6 years ago

jzztf commented 6 years ago

python 最简单的类

最简单的类创建了一个命名空间, 可如字典般储存信息

>>> class rec: pass
... 
>>> rec.name = 'John Smith'
>>> rec.age = '22'
>>> rec.name
'John Smith'
>>> rec.age
'22'
>>> info = rec    # 亦可实例化最小类
>>> info.name
'John Smith'
>>> info.age
'22'