Provide quotes as input command line in python [duplicate]
In a unix shell, to easily figure out the exact string you need to send to any commandline argument, you can use Python's shlex.quote()
:
>>> import shlex
>>> arg = r'''"fo\"o"'''
>>> print(shlex.quote(arg))
'"fo\"o"'
Make sure you wrap the argument with r
and triple quotes.
If you happen to have triple quotes in your string, you'll have to manually escape everything without using r
.