20190829 Python 練習記錄

>>> from enum import Enum,unique
>>> @unique
... class Weekday(Enum):
...     sum = 0
...     mon =1
...     tue =2
...     wed =3
...     thu=4
...     fri=5
...
>>> day1=Weekday.mon
>>> print(day1)
Weekday.mon
>>> print(Weekday['thu'])
Weekday.thu
>>> print(Weekday.thu.value)
4

>>> Hello=type('Hello',(object,),dict(hello=fn))
>>> h=Hello()
>>> h.hello
<bound method fn of <__main__.Hello object at 0x03AA00D0>>
>>> h.hello()
Hello,world
>>> 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章