PHP前端开发

python续行符是什么

百变鹏仔 3个月前 (01-23) #Python
文章标签 python

跨行的字面字符串可用以下几种方法表示。使用续行符,即在每行最后一个字符后使用反斜线来说明下一行是上一行逻辑上的延续。

以下使用 来添加新行:

>>> '"Isn't," she said.''"Isn't," she said.'>>> print('"Isn't," she said.')"Isn't," she said.>>> s = 'First line.Second line.'  #  意味着新行>>> s  # 不使用 print(),  包含在输出中'First line.Second line.'>>> print(s)  # 使用 print(),  输出一个新行First line.Second line.

  以下使用 反斜线() 来续行:

hello = "This is a rather long string containingseveral lines of text just as you would do in C.    Note that whitespace at the beginning of the line is significant." print(hello)