如何管理 Python 中的 twitch API 错误?
How to Manage twitch API Errors in Python?
我正在使用 twitch api(twitch-python 和 python-twitch-client)抓取 twitch。
我不确定应该如何管理这些 httperrors,因为我没有使用 urllib.request。
game = []
for a in lis[68:]:
b = client.videos.get_by_id(a).game
try:
game.append(b)
except Exception as e:
print(type(e))
即使我使用 except,这个错误仍然出现:
HTTPError:404 客户端错误:找不到 url:https://api.twitch.tv/kraken/videos/420146641
好的,我想我知道问题出在哪里了。您没有在 try
子句中包装正确的代码。 .append
不太可能引发错误,因此错误可能发生在您将 b
分配给某个 error-throwing 函数的输出时。将 for-loop 之后的第一行代码移动到 try
块中。
我正在使用 twitch api(twitch-python 和 python-twitch-client)抓取 twitch。
我不确定应该如何管理这些 httperrors,因为我没有使用 urllib.request。
game = []
for a in lis[68:]:
b = client.videos.get_by_id(a).game
try:
game.append(b)
except Exception as e:
print(type(e))
即使我使用 except,这个错误仍然出现: HTTPError:404 客户端错误:找不到 url:https://api.twitch.tv/kraken/videos/420146641
好的,我想我知道问题出在哪里了。您没有在 try
子句中包装正确的代码。 .append
不太可能引发错误,因此错误可能发生在您将 b
分配给某个 error-throwing 函数的输出时。将 for-loop 之后的第一行代码移动到 try
块中。