错误代码:
parser.add_argument('dump_file', help=('twitter downloader dump where each'
' line is a tweet in json format.'))
parser.add_argument('out_dir', help=('output directory path where parsed'
' tweets in json and cleaned text '
'file will be stored.'))
parser.add_argument('--cleaned_txt_out', nargs='?', default='big.txt')
parser.add_argument('--include_wd_file', nargs='?', default=None)
parser.add_argument('--exclude_wd_file', nargs='?', default=None)
parser.add_argument('--keep_duplicates', default=False, action='store_true')
错误提示:
usage: process_big.py [-h] [--cleaned_txt_out [CLEANED_TXT_OUT]]
[--include_wd_file [INCLUDE_WD_FILE]]
[--exclude_wd_file [EXCLUDE_WD_FILE]]
[--keep_duplicates]
dump_file out_dir
process_big.py: error: the following arguments are required: dump_file, out_dir
解决方法:提示中的两个参数少了 “–”。这里erro中后面的参数不一样无所谓,主要原因解决方法是一样的。
正确代码:
parser = argparse.ArgumentParser(description='Process twitter downloader dump.')
parser.add_argument('--dump_file', help=('twitter downloader dump where each'
' line is a tweet in json format.'))
parser.add_argument('--out_dir', help=('output directory path where parsed'
' tweets in json and cleaned text '
'file will be stored.'))
parser.add_argument('--cleaned_txt_out', nargs='?', default='big.txt')
parser.add_argument('--include_wd_file', nargs='?', default=None)
parser.add_argument('--exclude_wd_file', nargs='?', default=None)
parser.add_argument('--keep_duplicates', default=False, action='store_true')