python 解析python脚本参数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 解析python脚本参数相关的知识,希望对你有一定的参考价值。

import argparse

# Functions here

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Create Marketing Report')
    parser.add_argument('--accounts',
                        action='store_true',
                        help='Process Account Data')
    parser.add_argument('--sales',
                        action='store_true',
                        help='Process Sales Data')
    args = parser.parse_args()
    # Process accounts
    if args.accounts:
        # Do something
    # Process sales
    if args.sales:
        # Do Something

以上是关于python 解析python脚本参数的主要内容,如果未能解决你的问题,请参考以下文章