The rule of literal string

Li Han lihang9999 at gmail.com
Wed Dec 17 06:32:30 CET 2008


Hi! I just began to read the tutorial of python3.0 and I just can't
figure out the rule of literal string. There is a example in the
tuotrial:
>>> '"Isn\'t," she said.'
'"Isn\'t," she said.'
It is not what I want, I just want '"Isn't," she said.' be printed,
why the backslash failed?
These don't work at all:
>>> '''"Isn't," she said.'''
'"Isn\'t," she said.'
>>> r"Isn't," she said.
SyntaxError: invalid syntax (<pyshell#6>, line 1)
>>> r'"Isn't," she said.'
SyntaxError: invalid syntax (<pyshell#7>, line 1)
I have tried to solve it until my brain damaged and now I need to
sleep.



More information about the Python-list mailing list