I can call my script like this:
python D:\myscript.py 60
And in the script I can do:
arg = sys.argv[1] foo(arg)
But how could I test if the argument has been entered in the command line call? I need to do something like this:
if isset(sys.argv[1]): foo(sys.argv[1]) else: print "You must set argument!!!"
All the command line arguments are stored in a character pointer array called argv[ ].
Get Values of All the Arguments in Bash We can use the $* or the $@ command to see all values given as arguments. This code prints all the values given as arguments to the screen with both commands.
len(sys.argv) > 1
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