Created
March 14, 2021 15:53
-
-
Save thanakijwanavit/1fe546726782126d882b6553db760347 to your computer and use it in GitHub Desktop.
enum example python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from enum import Enum | |
| class Animal(Enum): | |
| cat=1 | |
| dog=2 | |
| def testEnum(te:Animal): | |
| animal:Animal = Animal[te] | |
| print(animal.name) | |
| print(animal.value) | |
| testEnum('cat') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment