python.py 文件源码

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

项目:GSM-scanner 作者: yosriayed 项目源码 文件源码
def _escape_bytes(val):
        """
        If val is pure ascii, returns it as a str(), otherwise escapes
        into a sequence of escaped bytes:
        b'\xc3\xb4\xc5\xd6' -> u'\\xc3\\xb4\\xc5\\xd6'

        note:
           the obvious "v.decode('unicode-escape')" will return
           valid utf-8 unicode if it finds them in the string, but we
           want to return escaped bytes for any byte, even if they match
           a utf-8 string.
        """
        # source: http://goo.gl/bGsnwC
        import codecs
        encoded_bytes, _ = codecs.escape_encode(val)
        return encoded_bytes.decode('ascii')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号