常規例外捕手記錄以下異常:如何知道在python中捕獲哪種異常類型?
> Traceback (most recent call last): File "4sq.py", line 37, in
> <module>
> checkin = client.checkins() File "/usr/local/lib/python2.7/dist-packages/foursquare-20120716-py2.7.egg/foursquare/__init__.py",
> line 416, in __call__
> return self.GET('{CHECKIN_ID}'.format(CHECKIN_ID=CHECKIN_ID), params, multi=multi) File
> "/usr/local/lib/python2.7/dist-packages/foursquare-20120716-py2.7.egg/foursquare/__init__.py",
> line 217, in GET
> return self.requester.GET(self._expanded_path(path), *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/foursquare-20120716-py2.7.egg/foursquare/__init__.py",
> line 163, in GET
> return self._request(url) File "/usr/local/lib/python2.7/dist-packages/foursquare-20120716-py2.7.egg/foursquare/__init__.py",
> line 200, in _request
> return _request_with_retry(url, data)['response'] File "/usr/local/lib/python2.7/dist-packages/foursquare-20120716-py2.7.egg/foursquare/__init__.py",
> line 696, in _request_with_retry
> return _process_request_with_httplib2(url, data) File "/usr/local/lib/python2.7/dist-packages/foursquare-20120716-py2.7.egg/foursquare/__init__.py",
> line 719, in _process_request_with_httplib2
> return _check_response(data) File "/usr/local/lib/python2.7/dist-packages/foursquare-20120716-py2.7.egg/foursquare/__init__.py",
> line 742, in _check_response
> raise exc(meta.get('errorDetail')) RateLimitExceeded: Quota exceeded
我想知道具體的異常名,所以我可以專門捕捉到它。 如何找到?
是否有對陷入異常的「類型」的功能,還是應該在投擲LIB的源中找到 - 可用here
看起來就像是一個'RateLimitExceeded'例外。雖然,可以肯定的是,我會將它封裝在'try' /'中,除了Exception as e'並打印'e .__ class__'。那會給你一個明確的答案 – inspectorG4dget
謝謝你正在尋找類似e .__ class__的東西! – user971956