Is there a component of Python that allows me to bypass intermediate quotation marks? As in, can you dictate the master start and stop to a print call, so that everything in between the master start and stop is interpreted regardless of what that element originally represents?
print" ./'..|'.|| |||||\``````` " '''''''/||||| ||.`|..`\."
^
SyntaxError: EOL while scanning string literal
Why not use a triple-quoted string that has """
on each end?
>>> print """ ./'..|'.|| |||||\``````` " '''''''/||||| ||.`|..`\."""
./'..|'.|| |||||\``````` " '''''''/||||| ||.`|..`\.
>>>
Note that you will still need to escape any triple quotes inside the string that match those on each end:
>>> print """ \""" """
"""
>>>
Another approach is to simply put the lines in a plaintext file and then read them in, as I would do in Linux/Unix:
$ cat > my_file.txt
./'..|'.|| |||||\``````` " '''''''/||||| ||.`|..`\.
^D <- control-d means end of file input from the command line
Then with Python:
with open('/path/my_file.txt') as f:
print f.read()
should output:
./'..|'.|| |||||\``````` " '''''''/||||| ||.`|..`\.
This does not answer the question. Just saying: Check whether you need an answer to the question above at all.<\/strong>
Instead, you do not need to care, and you should not care, see Python MySQL escape special characters<\/a> , and it might rather be the new aim to avoid the automatic escapes ( How to prevent automatic escaping of special characters in Python<\/a> which is then at the r<\/code> topic again).
If possible, you should leave it to a library function to deal with the special characters and pass your string(s) as args (arguments).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.