折腾:
【已解决】Python的Flask中自定义的枚举对象序列化为JSON时出错:TypeError is not JSON serializable
期间,想要去寻找,Python中是否有已经预定义好的,已实现的,类似于IntEnum的String的Enum
其中已经知道了:
Enum是Python 3.4之后才有的
此处的Python 2.12中,已通过导入enum34,得以使用上了enum.Enum了。
StringEnum
python enum string enum
python enum IntEnum
8.13. enum — Support for enumerations — Python 3.5.2 documentation
python enum StrEnum
enum34-custom 0.7.2 : Python Package Index
那就去试试这个:
结果找不到:
(RunningFast) ➜ staging pip install enum34-custom Collecting enum34-custom Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f70d4f09710>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/enum34-custom/ Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f70d378cb50>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/enum34-custom/ Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f70d378cd90>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/enum34-custom/ Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f70d378cc90>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/enum34-custom/ Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by ‘NewConnectionError(‘<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f70d378cb10>: Failed to establish a new connection: [Errno -2] Name or service not known’,)’: /simple/enum34-custom/ Could not find a version that satisfies the requirement enum34-custom (from versions: ) No matching distribution found for enum34-custom You are using pip version 8.1.2, however version 9.0.0 is available. You should consider upgrading via the ‘pip install –upgrade pip’ command. |
算了。不去找了。