Используйте formatter_class=argparse.RawTextHelpFormatter
, чтобы сохранить все пробелы в строке справки. Это строка справки приложения argparse
, а не docstring
. Может выглядеть немного уродливо, хотя:
parser = argparse.ArgumentParser(
prog='samplefind',
formatter_class=argparse.RawTextHelpFormatter,
description="""
Script to search for matches by word or lines in a text file and save the found information in a new outfile.txt file.
From command line run python sfind.py .
To view all available options: python sfind.py -h .
""")
С терминала:
py bla.py -h использование: samplefind [-h]
Script to search for matches by word or lines in a text file and save the found information in a new outfile.txt file.
From command line run python sfind.py .
To view all available options: python sfind.py -h .
Обратите внимание, что это включает пробелы от начала строки, новые строки, все.