writer.py 文件源码

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

项目:py2rb 作者: naitoh 项目源码 文件源码
def __init__(self, in_file = None):
        import sys
        self._line_wrap = False
        self._write_pos = 0
        self._file = in_file or sys.stdout
        #self._file = sys.stdout
        if not (hasattr(self._file, 'isatty') and self._file.isatty()):
            # the stdout is not a terminal, this for example happens if the
            # output is piped to less, e.g. "bin/test | less". In this case,
            # the terminal control sequences would be printed verbatim, so
            # don't use any colors.
            self.write = self.normal_write
        elif sys.platform != "win32":
            # We are on *nix system we can use ansi
            self.write = self.ansi_write
        else:
            try:
                import colorama
                colorama.init(wrap=False)
                self._file = colorama.AnsiToWin32(self._file).stream
                self.write = self.ansi_write
            except ImportError:
                self.write = self.normal_write
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号