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

前端 未结 11 828
猫巷女王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:53

    Based on the post by danben, here is my solution that works in IDLE:

    try:  
        sys.argv = ['fibo3_5.py', '30']  
        fibonacci(int(sys.argv[1]))  
    except:  
        print(str('Then try some other way.'))  
    

提交回复
热议问题