NameError: global name 'HTTPError' is not defined

后端 未结 4 1577
说谎
说谎 2021-01-04 01:16

I have a command in a try clause which I know throws an exception. I\'m trying to catch it in an \"except\" clause, but the except clause seems to not recognize the existen

4条回答
  •  一向
    一向 (楼主)
    2021-01-04 01:53

    You probably just need to import the HTTPError class before using it. Try inserting at the top of your actions.py file:

    from urllib2 import HTTPError
    

    and then you should be able to use your code as is.

提交回复
热议问题