how to handle a json that contains several results using python

Asked

Viewed 148 times

0

Hello, I’m making a python script that takes the name of a movie and returns some data to the user(title, year etc). I am using the omdbapi, but my doubt is not about it but about how to handle the following json http://www.omdbapi.com/? i=tt3896198&apikey=b34f7b7b&s=star+wars&type=Movie, when I use the t parameter it returns the data of a film only then it is good but when use s it returns several results and I’m having problems in how to print it.
Cod:https://github.com/Mathe13/movie_search/blob/master/movie_search.py

  • The recommendation is to put the code here along with the question. If the program is too long, the ideal is to reach a small point that can independently reproduce the problem you are encountering.

1 answer

1


Just change line 49:

for i in resposta.get('Search'):
    print('teste')
    print_movie_data(i)
  • thanks, helped mt. gave up on the code to show the results through the pages tbm

Browser other questions tagged

You are not signed in. Login or sign up in order to post.