来源:https://stackoverflow.com/questions/1077113/how-do-i-detect-whether-sys-stdout-is-attached-to-terminal-or-not
if sys.stdout.isatty():
# You're running in a real terminal
else:
# You're being piped or redirected
来源:https://stackoverflow.com/questions/1077113/how-do-i-detect-whether-sys-stdout-is-attached-to-terminal-or-not
if sys.stdout.isatty():
# You're running in a real terminal
else:
# You're being piped or redirected