我試圖爲執行我的Python腳本:解析Python中的命令行參數:得到一個KeyError異常
python series.py supernatural 4 6
Supernatural : TV Series name 4 : season number 6 : episode number
現在,在我的劇本我使用上述三個參數,以獲取事件的標題:
import tvrage.api
import sys
a = sys.argv[1]
b = sys.argv[2]
c = sys.argv[3]
temp = tvrage.api.Show(a)
name = temp.season(b).episode(c) # Line:19
print (name.title)
但我收到此錯誤:
File "series.py", line 19, in <module>:
name = super.season(b).episode(c)
File "C:\Python26\Lib\site-packages\tvrage\api.py", line 212, in season
return self.episodes[n] KeyError: '4'
我正在使用Python 2.6。
你能告訴我們錯誤嗎? – birryree
實際上錯誤是指向我使用的API,但如果你想錯誤是'File「series.py」,第19行,在 name = super.season(b).episode(c) 文件「C:\ Python26 \ Lib \ site-packages \ tvrage \ api.py「,第212行,在季節中 return self.episodes [n] KeyError:'4' –
RanRag