Python单引号,双引号,三引号

Python中的单引号”,双引号””,三引号””” “””,或者”’ ”’ 都可以用来包含字符串,三引号包含的字符串可由多行组成,一般可表示大段的叙述性字符串。在使用时基本没有差别,但双引号和三引号(”””…”””)中可以包含单引号,三引号(”’…”’)可以包含双引号,而不需要转义。
示例:

>>> x = 'I am alex'
>>> print(x)
I am alex

>>> y = "I'm alex"
>>> print(y)
I'm alex

>>> z = '''Be the change
... you want to see in the world!'''
>>> print(z)
Be the change
you want to see in the world!
    原文作者:Alex_Dj
    原文地址: https://www.jianshu.com/p/d3858d501a84
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞