https://blog.csdn.net/weixin_35653315/article/details/72886718
可以通过sys.argv和getopt组合来传参, 具体可参考以下:
import os
import sys
import getopt
def getArgs():
#get input parameter
input_path = "."
options, args = getopt.getopt(sys.argv[1:], "d:h", ["dir=", "help"])
for name_, value_ in options:
if name_ in ("-h", "--help"):
usage()
elif name_ in ("-d", "--dir"):
input_path = value_
else:
print "error! rename_rtvgps_file cannot find this option: " + name_
# print ("rename_rtvgps_file", "error", "cannot find this option: " + name_)
usage()
return input_path
def usage():
#help infomation
info = '''
python rename_rtvgps_file.py -d <filepath>
"-d","--dir" input the directory of rtv and imu files. default: './'
"-h","--help" print help info.
'''
print info
exit()