import argparse
parser = argparse.ArgumentParser(prog='myprogram', description='Process some files')
# Required arguments
parser.add_argument('input', help='The input file')
parser.add_argument('output', help='The output file')
# Optional arguments
parser.add_argument('-v', ' - verbose', action='store_true', help='Enable verbose output')
parser.add_argument('-o', ' - overwrite', action='store_true', help='Overwrite the output file if it exists')
parser.add_argument('-n', ' - num-records', type=int, default=10, help='The number of records to process')
# Mutually exclusive arguments
group = parser.add_mutually_exclusive_group()
group.add_argument('-u', ' - uppercase', action='store_true', help='Convert the output to uppercase')
group.add_argument('-l', ' - lowercase', action='store_true', help='Convert the output to lowercase')
# Arguments with choices
parser.add_argument('-c', ' - compression', choices=['gzip', 'bzip2', 'lzma'], help='The compression algorithm to use')
# Positional arguments with variable number of inputs
parser.add_argument(' - exclude', nargs='+', help='Exclude the specified files from processing')
# Parse the command line arguments
args = parser.parse_args()
'개발' 카테고리의 다른 글
[Python] 파이썬 관점에서의 OOP, FP (0) | 2023.01.06 |
---|---|
Streamlit 으로 data annotation 하는 법 (0) | 2023.01.05 |
[Python] Warning 무시하기 (0) | 2022.10.24 |
[VScode] (Mac) 에서 edit 에서 자꾸 i를 눌러야 수정이 되길래 (1) | 2022.10.14 |
[Keras] module 'keras.engine' has no attribute 'Layer' 문제해결 (0) | 2022.10.13 |
댓글