log.py 文件源码

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

项目:cobra 作者: wufeifei 项目源码 文件源码
def stdout_encode(data):
    try:
        data = data or ""

        # Reference: http://bugs.python.org/issue1602
        if mswindows:
            output = data.encode(sys.stdout.encoding, "replace")

            if '?' in output and '?' not in data:
                warn = "cannot properly display Unicode characters "
                warn += "inside Windows OS command prompt "
                warn += "(http://bugs.python.org/issue1602). All "
                warn += "unhandled occurances will result in "
                warn += "replacement with '?' character. Please, find "
                warn += "proper character representation inside "
                warn += "corresponding output files. "
                single_time_warn_message(warn)

            ret = output
        else:
            ret = data.encode(sys.stdout.encoding)
    except Exception as e:
        ret = data.encode(UNICODE_ENCODING) if isinstance(data, unicode) else data

    return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号