您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在python 3中覆盖__hex__?

在python 3中覆盖__hex__?

PEP3100(杂项Python 3.0计划)的目标之一是:

[删除] __oct____hex__使用:__index__oct()hex()代替。

要进行这项工作,您需要实现__index__,可能是:

def __index__(self):
    # or self._value if you kNow _value is an integer already
    return operator.index(self._value)

您可以在此处查看更改此行为的提交:

r55905 | georg.brandl | 2007-06-11 10:02:26 -0700 (Mon, 11 Jun 2007) | 5

lines

Remove __oct__ and __hex__ and use __index__ for converting
non-ints before formatting in a base.

Add a bin() builtin.
python 2022/1/1 18:42:22 有263人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶