>>> "it's a string"
"it's a string"
>>> 'it is "python"'
'it is "python"'
>>> s='''it's a string '''
>>> s
"it's\na\nstring\n"
>>> print(s)
it's
a
string
這樣寫如果用單引號或雙引號就會報錯,同時注意字符串裡的換行符。
>>> s='it\
is\
a\
strng\
'
>>> s
'itisastrng'
>>> 'it\'s a string'
"it's a string"
其他(忽略下面is顏色的不同)
>>> s='It\nis\tpython'
>>> s
'It\nis\tpython'
>>> print(s)
It
is python
>>> s=r"this\nis\na\nstring"
>>> s
'this\\nis\\na\\nstring'
>>> print(s)
this\nis\na\nstring