不是說r形式里不能表示包含單引號和雙引號的字符串嗎?
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
#這條語句是正確的,但是包含了單引號和雙引號
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
#這條語句是正確的,但是包含了單引號和雙引號
2019-04-10
舉報
2019-04-13
原文:
但是
r'...'
表示法不能表示多行字符串,也不能表示包含'
和?"
的字符串(為什么?)如果要表示多行字符串,可以用
'''...'''
表示2019-04-10
前面加r只是表明后面字符串里的符號不會被轉義,都是普通字符