print "NUCLEAR CORE UNSTABLE!!!, Quarantine is in effect. , Surrounding hamlets will be evacuated. , Anti-radiationsuits and iodine pills are mandatory."
print bcolors.WARNING + "NUCLEAR CORE UNSTABLE!!!" + bcolors.ENDC + '''\n Quarantine is in effect. \n
Surrounding hamlets will be evacuated. , Anti-radiationsuits and iodine pills are mandatory.'''
def printit():
print """NUCLEAR CORE UNSTABLE!!!
Quarantine is in effect.
Surrounding hamlets will be evacuated.
Anti-radiationsuits and iodine pills are mandatory.
"""
只需运行3次:
for i in range(3):
printit()
它使用多个print语句:
def printit():
print "NUCLEAR CORE UNSTABLE!!!"
print "Quarantine is in effect."
print "Surrounding hamlets will be evacuated."
print "Anti-radiationsuits and iodine pills are mandatory.\n"
这只使用一行内嵌的换行符:
def printit():
print "NUCLEAR CORE UNSTABLE!!!\nQuarantine is in effect.\nSurrounding hamlets will be evacuated.\nAnti-radiationsuits and iodine pills are mandatory.\n"
但是,您提到print函数并抱怨逗号分隔符没有起到任何作用,因此:
from __future__ import print_function
def printit():
print ("NUCLEAR CORE UNSTABLE!!!",
"Quarantine is in effect.",
"Surrounding hamlets will be evacuated.",
"Anti-radiationsuits and iodine pills are mandatory.\n",
sep="\n")
这是一个代码片段,我发现网上和作品
您也可以使用\t来放入制表符空间
您使用的是
print
语句,而不是函数,有几种方法:这将使用三重引号字符串来保留换行符:
只需运行3次:
它使用多个
print
语句:这只使用一行内嵌的换行符:
但是,您提到
print
函数并抱怨逗号分隔符没有起到任何作用,因此:我个人比较喜欢这个。您可以将所有代码放在一行中,但这会使代码难以读取和维护
相关问题 更多 >
编程相关推荐