I want the user to provide some external arguments while calling a python script from command line, what changes I suppose to make inside my python script to add this functionality?
I think this is what you are looking for
pass arguments in command line.
$ python test.py arg1 arg2 arg3
access it using sys.argv which gives list of arguments that you entered above
import sys
print 'Number of arguments:', len(sys.argv), 'arguments.'
print 'Argument List:', str(sys.argv)
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