【问题标题】:With Python Docopt, how can I have "one parameter or more required"?使用 Python Docopt,我怎样才能拥有“一个或多个参数”?
【发布时间】:2016-12-30 13:24:18
【问题描述】:

我现在有这样的事情。

Usage:
    main.py start without ([--db] [--faced] [--ird]) [--save]

我想要start without 至少具有--db--faced 和/或--ird 的一个或多个参数。

--save 将是一个可选参数。

所以python3 -B main.py start without 不起作用,python3 -B main.py start without --save 也不起作用。

我怎样才能做到这一点?

【问题讨论】:

    标签: python docopt


    【解决方案1】:

    目前我最好的解决方案。

    Usage:
        main.py start without ((--db) [--faced] [--ird]) [--save]
        main.py start without ([--db] (--faced) [--ird]) [--save]
        main.py start without ([--db] [--faced] (--ird)) [--save]
    

    我在我的 Reddit 线程 https://www.reddit.com/r/learnpython/comments/5l3k2m/with_python_docopt_how_can_i_have_one_parameter/ 中从 /u/ingolemo 找到了更好的解决方案

    main.py start without (--db|--faced|--ird)... [--save]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-26
      • 2023-03-04
      • 2022-09-29
      相关资源
      最近更新 更多