cli.py 文件源码

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

项目:download-npo 作者: Carpetsmoker 项目源码 文件源码
def term_width():
    """ Try and get the terminal width """

    # Python 3.3 and newer
    if getattr(os, 'get_terminal_size', None) is not None:
        try:
            return os.get_terminal_size().columns
        except OSError:
            pass

    # No reliable/easy way on Windows in 3.2 and older
    if sys.platform == 'win32':
        return 80

    try:
        proc = subprocess.Popen(['tput cols'], shell=True, stdout=subprocess.PIPE)
        out = proc.communicate()
        if proc.wait() != 0:
            raise OSError
        return int(out[0])
    except OSError:
        return 80
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号