Reputation: 2228
I'm trying to write a Python script which grabs command line arguments and uses them as search terms with the twitter api. I'd like to allow others using the script to insert a hashtag as a search term without having to escape the hash, or pound sign.
Here's a two line script illustrating my issue:
import sys
print "\n".join(sys.argv[1:])
Example usage:
$ python example.py one two \#three #four five
one
two
#three
$
Is there a way I could get in arguments which include a hash without forcing the user of the script to escape them?
Upvotes: 1
Views: 1239
Reputation: 186
You could put them in quotes.
python example.py one two "#three" "#four" five
Upvotes: 3