我想计算结果 JSON 对象的数量:我该怎么办?
我有这个功能:(问题出在“for i in r:”)
import urllib
import json
from classes import ricerca_IMDB
def search_IMDB (titolo):
sito='http://www.omdbapi.com/?s='+titolo
r=0
r=json.loads(urllib.urlopen(sito).read())
i=0
filmList = []
try:
for i in r:
filmList.append(ricerca_IMDB(r['Search'][i]['Title'], r['Search'][i]['Year'], r['Search'][i]['imdbID']))
except:
filmList = []
return filmList