0

The content of string is like this, and it has many " and many ', below is just a simple example, is there a way I can represent such a string as a constant string and assign to a variable without escape " and '. Just want to save some typing for escape " and ' and make string more readable in code. :)

--pretty-print "http://foo.com" {'bbb'}

BTW: using Python 2.7.

thanks in advance, Lin

1
  • 3
    With triple-quoted strings: """ or ''' Commented May 12, 2016 at 0:19

1 Answer 1

2

Use triple quotes, either single or double. You can have multiple lines in triply-quoted strings, but you don't have to.

option = """--pretty-print "http://foo.com" {'bbb'}"""
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks kindall, vote up and mark your reply as answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.