我有以下代码:
def coming_episode ( show ):
try:
show = api.search ( show , 'en' ) [ 0 ]
except:
print "a"
return
announced = [ 'show title' ]
for e in show [ len ( show ) -1 ]:
if e.FirstAired != '' and time.time () < time.mktime ( e.FirstAired.timetuple () ):
announced.append ( [ e.EpisodeName , e.id , time.mktime ( e.FirstAired.timetuple () ) ] )
return announced
当我寻找 TVDB api 中存在的节目时,这很好用。但是,当我输入一些愚蠢的东西时,我也想捕获异常,例如“awdawd”作为表演。
我试过了except:
,except TVDBIndexError:
但仍然给我以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "init.py", line 27, in <module>
series = coming_episode ( series )
File "init.py", line 19, in coming_episode
for e in show [ len ( show ) -1 ]:
File "/Users/Sites/Python/_envs/Series/lib/python2.7/site-packages/pytvdbapi/api.py", line 340, in __getitem__
raise error.TVDBIndexError("Season {0} not found".format(item))
pytvdbapi.error.TVDBIndexError: (u'Season 0 not found', (), {})
我在这里做错了什么?
提前致谢 ;)