轉義字符的應用
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
跟
s = 'Python was started in 1989 by \"Guido\".\nPython is free and easy to learn.'
意義上有不同嗎
s = 'Python was started in 1989 by "Guido".\nPython is free and easy to learn.'
跟
s = 'Python was started in 1989 by \"Guido\".\nPython is free and easy to learn.'
意義上有不同嗎
2019-02-25
舉報
2019-02-25
1.
類似的,如果字符串包含
"
,我們就可以用' '
括起來表示:2.
如果字符串既包含
'
又包含"
怎么辦?這個時候,就需要對字符串的某些特殊字符進行“轉義”,Python字符串用
\
進行轉義。