Python - print until marker (a la PHP)?
In PHP I can do this:
print <<<END
This uses the "here开发者_StackOverflow社区 document" syntax to output
multiple lines
END;
Is there a way to do something similar in Python?
I want to dump a big chunk of HTML without worrying about escaping e.g. angle brackets.
Python doesn't have heredocs with arbitrary start/end markers. You can use triple quotes (either single or double) to achieve something very similar:
print '''
This uses the "here document" syntax to output
multiple lines
'''
Add an r
to make it a raw string so that backslash is also not treated specially. r'''....'''
精彩评论