Python中的换行?
我想找一段用Python写的代码,这段代码在某个函数里面添加了一行新内容。
我应该搜索哪个字符呢?是\n
吗?
谢谢。
3 个回答
0
在Python字符串中,如果你想添加一个新行,可以使用 \n
。举个例子:
#Code
string = "Hello\nWorld"
print(string)
#Result
Hello
World
2
你想要的换行可能是自动加上的:要注意Python的print语句。如果最后一个参数后面没有逗号,它会自动加一个换行。
5
是的,在字符串中通常会用到 \n
来表示换行。不过,有时候也可能会有多行字符串,像这样:
'''
Some string
with
enters.
'''