sys库

image.png

常用参数

image.png
image.png
image.png
image.png

SUM

image.png

getopt库

image.png
image.png

代码示例**待完成

  1. import getopt,sys
  2. try:
  3. opts,args = getopt.getopt(sys.argv[1:],"hi:v",["distpath=","clean"])
  4. for o,a in opts:
  5. if o == "h":
  6. print("发现h新参数")
  7. elif o == "-v":
  8. print("发现-v新参数")
  9. elif o == "-i":
  10. print("发现-i参数及其对应值{}".format(a))
  11. elif o == "--distpath":
  12. print("发现--distpath参数及其对应值{}".format(a))
  13. elif o == "--clean":
  14. print("发现--clean新参数")
  15. else:
  16. print("发现未知参数")
  17. except getopt.GetoptError:
  18. print("命令行解析错误")
  19. sys.exit(2)

ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.

命令行解析错误
Traceback (most recent call last):
File ““, line 4, in
opts,args = getopt.getopt(sys.argv[1:],”hi:v”,[“distpath=”,”clean”])
File “D:\SoftWares\ImageProcess\Anaconda3\envs\pytorch\lib\getopt.py”,
…….