如何通过传递参数在pycharm中运行python程序?

时间:2015-08-07 18:18:50

标签: python python-2.7

我目前在pycharm中运行python程序时遇到问题,我通常用右键单击并运行程序。我想像这样运行程序:

python hrllo.py rahulkapoo vit university

这是我得到的错误:

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 个答案:

答案 0 :(得分:1)

在PyCharm中,右键单击脚本(或在打开脚本的编辑器窗口中,单击Create 'scriptname',将参数放在顶部附近的Script Parameters框中,然后单击{{1 }}

新的运行配置将显示在Pycharm顶部的运行按钮的左侧(至少在我的版本中)。现在确保在运行脚本时列出了新的运行配置。