This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008年10月21日 20:10 by cliffdover88, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg75038 - (view) | Author: Felipe (cliffdover88) | Date: 2008年10月21日 20:10 | |
Hi I have a problem with python 2.6, when i try to process strings with triple-quoted string literal i get an error: a='a''a' #1 double quoted Ok a='a''''a' # 2 Ok a= 'a''''''a' # 3 doble quoted -- SyntaxError: EOF while scanning triple-quoted string literal a= 'a''''''''a' # 4 ok a='a''''''''''a' # 5 same error impair doble quoted a='a''''''''''''a' # 6 Ok............... a... #7 error.................. |
|||
| msg75047 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) | Date: 2008年10月21日 21:05 | |
All your samples explain easily if you consider that two adjacent string
literals are joined together. (You seem to consider that "double quote"
is a way to insert a quote character. It's not; Python is not Pascal or
SQL)
Your first two examples become:
a='a''a' two adjacent strings == 'aa'
a='a''''a' three adjacent strings ('a' + '' + 'a') == 'aa'
The third is an error:
a='a''''''a' one string ('a') followed by the beginning of a "triple
quoted string" (''') which content starts with the characters (''a') but
does not have a matching (''') to finish the string, hence the Syntax
error.
... and so on. Please have a look at http://docs.python.org/reference/lexical_analysis.html#string-literals
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:40 | admin | set | github: 48414 |
| 2008年10月21日 21:05:19 | amaury.forgeotdarc | set | status: open -> closed resolution: not a bug messages: + msg75047 nosy: + amaury.forgeotdarc |
| 2008年10月21日 20:10:24 | cliffdover88 | create | |