from optparse import OptionParser
parser = OptionParser()

parser.add_option('-f', '--file', dest='filename', help='test')
# action 指定目的dest 存储的默认值 有时候参数不是必须的就可以设置action类型的默认值例如 true, false等
#常用的有 store也是默认值, store_false store true 等等
#dest 存储的目的变量名
#help 为帮助提示信息

(options, args) = parser.parse_args() #解析输入参数

print(options.filename, args)

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2022-01-01
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-21
  • 2021-06-25
  • 2021-05-20
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
相关资源
相似解决方案