Python 中的引号

pythonserver side programmingprogramming更新于 2023/12/11 0:40:00

Python 接受单引号 (')、双引号 (") 和三引号 (''' 或 """) 来表示字符串文字,只要字符串的开头和结尾是同一种类型的引号即可。

三引号用于将字符串跨越多行。例如,以下所有内容都是合法的 −

word = 'word'
sentence = "This is a sentence."
paragraph = """This is a paragraph. It is
made up of multiple lines and sentences."""

相关文章