In this article we will see how we get the birth date of any person, we can get retrieve the person data with the help of get_person method by passing the person id. get_person method returns a imdb Person object which can be used as a dictionary i.e. they can be queried by giving the key of the data, here key will be birth date.
Syntax : person[‘birth date’] Here person is the Person object return by the get_person method. Return : It return string which is birth date.
Below is the implementation.
Python3
# importing the module import imdb # creating instance of IMDb ia = imdb.IMDb() # person id person_id = " 1596350 " # getting person details search = ia.get_person(person_id) # printing the search # printing name and birth date print (search[ 'name' ] + " " + search[ 'birth date' ]) |
Output :
Nawazuddin Siddiqui 1974-05-19
Time complexity of the code is O(1) as it involves only a single operation which is accessing the details of the person from the IMDb object.
Space complexity of the code is O(1) as it does not require any additional memory to store the search results.
Another example
Python3
# importing the module import imdb # creating instance of IMDb ia = imdb.IMDb() # person id person_id = " 0000206 " # getting person details search = ia.get_person(person_id) # printing the search # printing name and birth date print (search[ 'name' ] + " " + search[ 'birth date' ]) |
Output :
Keanu Reeves 1964-09-02