How to read/process command line arguments?

后端 未结 17 2084
离开以前
离开以前 2020-11-21 05:14

I am originally a C programmer. I have seen numerous tricks and \"hacks\" to read many different arguments.

What are some of the ways Python programmers can do this

17条回答
  •  眼角桃花
    2020-11-21 05:24

    #set default args as -h , if no args:
    if len(sys.argv) == 1: sys.argv[1:] = ["-h"]
    

提交回复
热议问题