memo-2018_1124_1150

memo-2018_1124_1150

"""
print(*objects, sep, end, file, flush)
objects: 出力対象のオブジェクト。
sep: 区切り文字(セパレータ)。デフォルトで半角空白。
end: 最後の要素の末尾に付けられる文字。デフォルトで改行文字。
file: 出力先。デフォルトで標準出力。標準エラー出力やファイルオブジェクトなどを指定可能。
flush: バッファなしで出力するかどうか。デフォルトでFalse で、出力先によって自動的に定められる。
"""

python -c 'print("print to stdout")' 2>/dev/null
print to stdout

python -c 'import sys
print("print to stderr", file=sys.stderr)' 2>/dev/null

python -c 'import sys
print("print to stderr", file=sys.stderr)' 2>&1
print to stderr

 
 

cf. 2. 組み込み関数

https://docs.python.jp/3/library/functions.html#print

cf. Python 3 の print() 関数の使い方

https://www.lifewithpython.com/2017/06/python-3-print.html

コメント

タイトルとURLをコピーしました