def get_terminal_width(fd=1):
"""
Returns width of terminal if it is a tty, 999 otherwise
:param fd: file descriptor (default: 1=stdout)
"""
if os.isatty(fd):
width = os.get_terminal_size(fd)[0]
else:
width = 50
return width
评论列表
文章目录