Red*_*ddy 4 python newline string-formatting
我格式化字符串(在重载运算符str),我不想使用原始\n或\ r \n标记.在C++中有像std :: endl这样的python跨平台换行符标识符吗?
我试图谷歌,但没有找到答案.
übe*_*sus 15
怎么用os.linesep?它包含适用于您的操作系统的相应行分隔符:
>>> import os
>>> os.linesep
'\n'
>>> print "line one" + os.linesep + "line two"
line one
line two
Run Code Online (Sandbox Code Playgroud)