import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--date', help='date of event', type=str)
parser.add_argument('-t', '--time', help='time of event', type=str)
args = parser.parse_args()
print(f'Event was on {args.date} at {args.time}')
import argparse
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-n", "--name", required=True, help="name of the user")
args = vars(ap.parse_args())
# display a friendly message to the user
print("Hi there {}, it's nice to meet you!".format(args["name"]))
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('file', type=argparse.FileType('r'))
args = parser.parse_args()
print(args.file.readlines())
import argparse
if __name__ == "__main__":
#add a description
parser = argparse.ArgumentParser(description="what the program does")
#add the arguments
parser.add_argument("arg1", help="advice on arg")
parser.add_argument("arg2", help="advice on arg")
# .
# .
# .
parser.add_argument("argn", help="advice on arg")
#this allows you to access the arguments via the object args
args = parser.parse_args()
#how to use the arguments
args.arg1, args.arg2 ... args.argn
python Application.py -env="-env"