How to run python programs in pycharm with passing parameters?

牧云@^-^@ 提交于 2021-02-08 11:58:18

问题


I am currently having problem running python programs in pycharm, I generally used to right click and run the program. I want to run the program like this:

python hrllo.py rahulkapoo vit university

Here is the error I get:

Traceback (most recent call last):
  File "C:/Users/rahul/PycharmProjects/untitled/hrllo.py", line 107, in <module>
    aggregate()
  File "C:/Users/rahul/PycharmProjects/untitled/hrllo.py", line 88, in aggregate
    br = login()
  File "C:/Users/rahul/PycharmProjects/untitled/hrllo.py", line 23, in login
    response = br.open('https://academics.vit.ac.in/student/stud_login.asp')
  File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 203, in open
    return self._mech_open(url, data, timeout=timeout)
  File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 255, in _mech_open
    raise response
mechanize._response.httperror_seek_wrapper: HTTP Error 403: request disallowed by robots.txt

Process finished with exit code 1

回答1:


In PyCharm, right-click on the script (or within the editor window that has the script open, click Create 'scriptname', put your params in the Script Parameters box near the top and click OK.

The new run config will appear to the left of the run button at the top of Pycharm (at least in my version it does). Now make sure that the new run config is listed when running the script.



来源:https://stackoverflow.com/questions/31884252/how-to-run-python-programs-in-pycharm-with-passing-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!