當有這個結構'''...'''的時候有沒有r好像沒影響啊
print r'''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
print '''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
這里有沒有r其實沒有影響啊
print r'''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
print '''"To be,or not to be":that is the question.
Whether it's nobler in the mind to suffer.'''
這里有沒有r其實沒有影響啊
2016-03-01
舉報
2016-03-01
因為引號里面沒有轉義字符,所以看不出差別。試試這兩個的差別:
print r'''"To be,or not to be":that is the question.\nWhether it's nobler in the mind to suffer.'''?
print '''"To be,or not to be":that is the question.\nWhether it's nobler in the mind to suffer.'''
2016-03-01
r''表示''內部的字符串默認不轉義,所以加了r的'''...'''里面的雙引號沒有轉譯,同時我測試了'''...'''不加r的單引號和雙引號結果都沒有轉譯,說明'''...'''內可以多行和帶單引號以及雙引號??!
所以沒有影響! ??
?不過遇到輸入 \b (退格Backspace),\n(換行?){我說的是字符哈!}等情況就要加r
2016-03-01
我也是這么覺得
2016-03-01
shiya