2024-09-26 17:45:12 发布
网友
如何在Python中添加CMD换行符? 我试过下面的内容,但还是以段落的形式出现。在
print "Welcome to xbrEra's first application"; print print " using Python 2.7.1. I hope you enjoy"; print print "-------------------------------------"; print
Python的print stmt会自动添加一个newline(它可能是'\r\n'或'\n',具体取决于您的操作系统)。如果不想添加换行符,可以用逗号结束打印语句。与print "hello,world",类似,您也可以在字符串中显式地添加换行控制字符来达到这种效果。在
newline
print "hello,world",
取决于您的操作系统:
print "\n"
或者
如果您真的想控制一个纯文本块的格式,请使用三重引号的字符串。在
print """ Welcome to xbrEra's first application using Python 2.7.1. I hope you enjoy - """
Python的print stmt会自动添加一个
newline
(它可能是'\r\n'或'\n',具体取决于您的操作系统)。如果不想添加换行符,可以用逗号结束打印语句。与print "hello,world",
类似,您也可以在字符串中显式地添加换行控制字符来达到这种效果。在取决于您的操作系统:
或者
^{pr2}$如果您真的想控制一个纯文本块的格式,请使用三重引号的字符串。在
相关问题 更多 >
编程相关推荐