Reputation: 1525
The following is my python script
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('query', nargs='*')
args = parser.parse_args()
print args.query
If I rum this with an argument like:
python script.py use of \n
It gives me the following output:
['use', 'of', 'n']
whereas I would like to have
['use', 'of', '\\n']
and so on.
Upvotes: 2
Views: 2097
Reputation: 3741
You should be getting this behavior on linux where '\' is shell escape character. It is used to continue a long command in next line. So you can write a long command in multi line by using '\' character. When you run
python script.py use of \n
shell take '\n' as two char '\' a escape char and 'n', Solution should be
python script.py use of \\n
or
python script.py use of '\n'
Upvotes: 1