I use the triple string in the following way:
str="""jeff"""
str=""""jeff"""
str=""""jeff"""" # error
str=""""jeff """"
The third one is error, could anyone explain why this is error ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Three quotes terminate a string, so this
is parsed as this:
The trailing quote is the problem.
BTW, looking at the BNF definition
it’s obvious that the star
*is non-greedy, I don’t know though if this is documented somewhere.In response to the comment, this
is interpreted as
and this
is interpreted as