unicode.py 文件源码

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

项目:centos-base-consul 作者: zeroc0d3lab 项目源码 文件源码
def out_u(s):
    '''Return unicode string suitable for displaying

    Unlike other functions assumes get_preferred_output_encoding() first. Unlike 
    u() does not throw exceptions for invalid unicode strings. Unlike 
    safe_unicode() does throw an exception if object is not a string.
    '''
    if isinstance(s, unicode):
        return s
    elif isinstance(s, bytes):
        return unicode(s, get_preferred_output_encoding(), 'powerline_decode_error')
    else:
        raise TypeError('Expected unicode or bytes instance, got {0}'.format(repr(type(s))))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号