When running a python script in IDLE, is there a way to pass in command line arguments (args)?

前端 未结 11 835
猫巷女王i
猫巷女王i 2020-12-02 13:08

I\'m testing some python code that parses command line input. Is there a way to pass this input in through IDLE? Currently I\'m saving in the IDLE editor and running from a

11条回答
  •  日久生厌
    2020-12-02 13:50

    import sys

    sys.argv = [sys.argv[0], '-arg1', 'val1', '-arg2', 'val2']

    //If you're passing command line for 'help' or 'verbose' you can say as:

    sys.argv = [sys.argv[0], '-h']

提交回复
热议问题