import json
top = json.load(open('top250.json'))
len(top)
250
top[0]
{u'actors': [u'Tim Robbins', u'Morgan Freeman', u'Bob Gunton'], u'director': u'Frank Darabont', u'imdb': u'0111161', u'title': u'Les \xe9vad\xe9s', u'year': u'1994'}
top[10]["title"]
u"Le seigneur des anneaux: La communaut\xe9 de l'anneau"
print(top[0]["title"])
Les évadés
top[0+1]
{u'actors': [u'Marlon Brando', u'Al Pacino', u'James Caan'], u'director': u'Francis Ford Coppola', u'imdb': u'0068646', u'title': u'Le parrain', u'year': u'1972'}
print("coucou")
coucou
for film in top:
if "Inception" in film["title"]:
print(film["actors"])
[u'Leonardo DiCaprio', u'Joseph Gordon-Levitt', u'Ellen Page']
"year" in top[0]
True
for i in range(250):
if "Lego" in top[i]["title"]:
print(i+1)
242
top[0]["year"]
u'1994'
for film in top:
if film["year"] == "1994":
print(film["title"])
Les évadés Pulp Fiction Forrest Gump Léon Le roi lion Trois couleurs: Rouge
top[0]["year"] in 1994
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-36-d7e63c8e4c9d> in <module>() ----> 1 top[0]["year"] in 1994 TypeError: argument of type 'int' is not iterable
2 in [1, 2, 5]
True
fNatalie Portma
The Dark Knight: Le chevalier noir Inception Memento The Dark Knight Rises Le prestige Batman Begins
for film in top :
if film in (["Natalie Portman"]
print(film["title"])
File "<ipython-input-55-3b7066102d5f>", line 3 print(film["title"]) ^ SyntaxError: invalid syntax
for film in top:
if film(("actors") in ("Nathalie Portman"):
print(film("title"))
File "<ipython-input-68-519ed04614fc>", line 2 if film(("actors") in ("Nathalie Portman"): ^ SyntaxError: invalid syntax
print("coco")
coco