1, the command line parameters of the problem
(1) learn to use the module getopt
Instructions:
try:
# h 代表不需要带值,m: 代表需要带值,且两者均为短参数
# model= 和 output= 均为长参数,且均需带值
opts, args = getopt.getopt(sys.argv[1:], "hm:o:", ["model=", "output="])
except getopt.GetoptError:
print('deeptext_gen_config -m <deepcrf|cls-rnn|cls-cnn> -o <output path>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('deeptext_gen_config -m <deepcrf|cls-rnn|cls-cnn> -o <output path>')
sys.exit()
elif opt in ("-o", "--output"):
path = arg
elif opt in ("-m", "--model"):
model = arg
reference:
sys.argv and getopt.getopt () usage : https://www.cnblogs.com/zz22--/p/9336569.html