I found this to be the only one short + flexible + portable + readable:
(我发现这是唯一的简短+灵活+便携式+可读的格式:)
from __future__ import print_function
import sys
def eprint(*args, **kwargs):
print(*args, file=sys.stderr, **kwargs)
The function eprint
can be used in the same way as the standard print
function:
(可以使用与标准print
功能相同的方式使用eprint
功能:)
>>> print("Test")
Test
>>> eprint("Test")
Test
>>> eprint("foo", "bar", "baz", sep="---")
foo---bar---baz
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…