私のPythonのバージョンは次のとおりです。
~$ python --version
Python 2.6.6
Pythonで次のことを試しました(すべて表示したい):
1: \
エスケープシーケンスとして使用
>>> str('Let\'s Python')
"Let's Python"
2: \
エスケープシーケンスとして使用
>>> 'Let\'s Python'
"Let's Python"
3:str()
タイプではなく値として出力
>>> print 'Let\'s Python'
Let's Python
4: その Python は生の文字列です
>>> repr('Let\'s Python')
'"Let\'s Python"'
[質問]
5: Python 生文字列
>>> print r'Let\'s Python'
Let\'s Python
6: これは、次のことがわかりません。
>>> r'Let\'s Python'
"Let\\'s Python"
>>> r'\\'
'\\\\'
なぜ\\
ですか?output in5
と6
が異なるのはなぜですか?
r
とrepr()
同じではありませんか? また、との内部表現が同じか異なるか
について説明してください。string
raw strings