【发布时间】:2019-05-30 13:06:04
【问题描述】:
为什么在我的代码中使用了 os.linesep()?
def GetInstruction():
print(os.linesep)#<--------???
Instruction = input("> ").lower()
return Instruction
【问题讨论】:
-
我不知道,为什么你的代码中被
os.linesep使用了? -
不同操作系统的行分隔符不同。这样代码就独立于操作系统了。
-
@MichaelButscher:行尾翻译默认发生,
print默认打印行尾,所以在这里使用os.linesep不会使事情变得更加独立于操作系统。我认为这段代码实际上可能会在 Windows 上产生\r\r\n\r\n。 -
@user2357112,你是对的。谢谢。
标签: python python-3.x python-2.7 python-requests