NOTE : I don't know if this has been asked before, but I couldn't find what wording would be used for asking this question
I am creating a python file, and inside it needs to have a name of a file.
What I want is when you put python Compiler.py <Filename> in the command line, it takes the filename and uses it in the python file.
How would I go about doing this?
someVariable = sys.argv[1]
This will take the first element after the file name and store it in the variable.
someOtherVariable = sys.argv[2]
will take the second element, and so forth.
python Compiler.py firstArg secondArg NthArg
Note: You will need to import sys to use the sys module.
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