最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】寻找Python中是否有已实现好的类似于IntEnum的String的Enum

Python crifan 2325浏览 0评论

折腾:

【已解决】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.

算了。不去找了。

转载请注明:在路上 » 【记录】寻找Python中是否有已实现好的类似于IntEnum的String的Enum

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.160 seconds, using 22.14MB memory