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?
I am trying to print this line for some fun ASCII in a program and this is just one of the lines I'm getting errors on due to intermediary quotation marks popping up:
print" ./'..|'.|| |||||\``````` " '''''''/||||| ||.`|..`\."
^
SyntaxError: EOL while scanning string literal
Edit: While considering the raw interpretation of string literals, you can also run into the triple-quoted exit within the raw interpretation should the triple quote appear in your line.
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:
./'..|'.|| |||||\``````` " '''''''/||||| ||.`|..`\.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With