Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
httpie次の 2 つのケースでは、python ツールが異なる結果をもたらすことに気付きました。
httpie
$ http google.com
$ http google.com > out.txt
ファイルout.txtには、最初のケースに存在するヘッダーがありません。
out.txt
sys.stdout.isatty端末 (「tty」) かファイルかを判別stdoutし、それに応じて異なる出力を出力するために使用します。たとえば、次のようになります。
sys.stdout.isatty
stdout
import sys if sys.stdout.isatty(): print "Hello terminal!" else: print "Hello non-terminal!"