Possible Duplicate:
Command Line Arguments In Python
I am using Python 3.2. What I would like to do is basically a program that exports text into a .txt file, like this:
[program name] "Hello World" /home/marcappuccino/Documents/Hello.txt
I am a newbie and I dont know how to take whtever’s in between the two “”s and place that into a variable. Is it in sys.argv?
Any help is appreciated! Thanks.
Yes, it is sys.argv, which holds the command line arguments. You would want something like:
This would assign “Hello World” to
string_to_insertand /home/marcappuccino/Documents/Hello.txt tofile_to_put_string_in.Let’s say you have a script named “dostuff.py” and you invoke it like this:
What you will end up with is:
Arguments in quotes are considered a single argument.