Answers for "running python script with arguments"

9

python arguments

import sys

print ("the script has the name %s" % (sys.argv[0])
Posted by: Guest on November-18-2019
0

cli args python

import argparse

parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
                   help='an integer for the accumulator')
parser.add_argument('--sum', dest='accumulate', action='store_const',
                   const=sum, default=max,
                   help='sum the integers (default: find the max)')

args = parser.parse_args()
print(args.accumulate(args.integers))
Posted by: Guest on October-20-2020

Code answers related to "running python script with arguments"

Python Answers by Framework

Browse Popular Code Answers by Language