python.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码
def __repr__(self):
        # Infinities aren't compared using tolerances, so don't show a
        # tolerance.
        if math.isinf(self.expected):
            return str(self.expected)

        # If a sensible tolerance can't be calculated, self.tolerance will
        # raise a ValueError.  In this case, display '???'.
        try:
            vetted_tolerance = '{:.1e}'.format(self.tolerance)
        except ValueError:
            vetted_tolerance = '???'

        plus_minus = u'{0} \u00b1 {1}'.format(self.expected, vetted_tolerance)

        # In python2, __repr__() must return a string (i.e. not a unicode
        # object).  In python3, __repr__() must return a unicode object
        # (although now strings are unicode objects and bytes are what
        # strings were).
        if sys.version_info[0] == 2:
            return plus_minus.encode('utf-8')
        else:
            return plus_minus
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号