在Python中添加CMD linebreak

2024-09-26 17:45:12 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在Python中添加CMD换行符? 我试过下面的内容,但还是以段落的形式出现。在

print "Welcome to xbrEra's first application";
print
print " using Python 2.7.1. I hope you enjoy";
print
print "-------------------------------------";
print

Tags: tocmdyou内容application形式first段落
3条回答

Python的print stmt会自动添加一个newline(它可能是'\r\n'或'\n',具体取决于您的操作系统)。如果不想添加换行符,可以用逗号结束打印语句。与print "hello,world",类似,您也可以在字符串中显式地添加换行控制字符来达到这种效果。在

取决于您的操作系统:

print "\n" 

或者

^{pr2}$

如果您真的想控制一个纯文本块的格式,请使用三重引号的字符串。在

print """
Welcome to xbrEra's first application
 using Python 2.7.1. I hope you enjoy
                  -
"""

相关问题 更多 >

    热门问题