Arguments
URL
https://docs.python.org/3/library/argparse.html https://docs.python.org/3/library/argparse.html#argparse.FileType
Arguments
1import argparse
2
3parser = argparse.ArgumentParser(description="Process some arguments.")
4parser.add_argument('-n','--name', type=str, help='Your name', default='Guest')
5parser.add_argument('-p','--password', type=str, help='Your password')
6parser.add_argument('-a', '--age', type=int, help='Your age in years')
7
8args = parser.parse_args()
9
10print(f'Hello, {args.name}!')
11print(f'Your password is: {args.password}')
12print(f'Your age is: {args.age}')The following file types for the argparse.FileType argument are supported:
str: Stringint: Integerfloat: Floating point numberbool: Booleanlist: Listtuple: Tupledict: Dictionary