간단한 단어 가드를 만들려고합니다. urbandict.py을 Python 2.7에 설치했습니다. 이 API는 JSON 객체를 통해 데이터를 처리합니다. 단어가 도시 사전에 있다면 나는 사실을 원한다. 그렇지 않으면 거짓이다.목록 색인 범위를 벗어남 오류 : urbandict.py
import urbandict
ur = urbandict.define("ice")
오류 : 나는 색인을 처리하기 위해 시도했지만 프로그램이 멀리 그것을하지 않습니다
Traceback (most recent call last):
File "C:\Users\dmurp_000\Desktop\wordFuntcion.py", line 15, in <module>
ur = urbandict.define("ice")
File "C:\Python27\lib\urbandict.py", line 86, in define
urbanDictParser.feed(data)
File "C:\Python27\lib\HTMLParser.py", line 114, in feed
self.goahead(0)
File "C:\Python27\lib\HTMLParser.py", line 152, in goahead
if i < j: self.handle_data(rawdata[i:j])
File "C:\Python27\lib\urbandict.py", line 72, in handle_data
self.translations[-1]['example'] += data.replace('\r', '\n')
**IndexError: list index out of range**
. 도움이 될 것입니다.
elif self.inside_example_section is True:
if len(self.translations) >= 1:
self.translations[-1]['example'] += data.replace('\r', '\n')
(https://github.com/novel/py-urbandict)? – 2rs2ts
감사합니다 게놈, 이건 내 문제가 해결 !! – dmurphy
'urbandictionary.com'이 html 마크 업을 변경 한 것 같습니다 (webarchive의 이전 마크 업 참조) (http://web.archive.org/web/20140101045756/http://www.urbandictionary.com/define. 현재 HTML 마크 업에서 작동하는 ['urbandictionary.py'] (https://gist.github.com/zed/9903390)입니다. ['urbandictionary.py']에 대한 pull 요청에 자유롭게 적용하십시오. py-urbandict'] (https://github.com/novel/py-urbandict) – jfs