我正在从Zed Shaw的LP3THW书中学习python。在“练习10。那是什么?”中。本章的代码是这样的:
currentArchiveFolder
o / p是这个:
1 tabby_cat = "\tI'm tabbed in."
2 persian_cat = "I'm split\non a line."
3 backslash_cat = "I'm \\ a \\ cat."
4
5 fat_cat = """
6 I'll do a list:
7 \t* Cat food
8 \t* Fishies
9 \t* Catnip\n\t* Grass
10 """
11
12 print(tabby_cat)
13 print(persian_cat)
14 print(backslash_cat)
15 print(fat_cat)
三个双引号“”“ 从 5行开始,到 10行结束。它们是做什么的,请帮忙。< / p>
答案 0 :(得分:0)
使用"""
可以将字符串分成几行,并按照文本编辑器中的显示输出。使用python进行编码时,通常使用"string"
,但是如果您尝试编写
print("This will go
on to the next line")
由于换行,您将收到一个错误。使用"""string"""
可以阻止此情况,
print("""This will go
on to the next line""")
将成功运行且没有错误,但是将保留换行符,并生成输出:
This will go
on to the next line