Wednesday, July 3, 2024
HomeLanguagesPythonPython IMDbPY – Getting birth place of person

Python IMDbPY – Getting birth place of person

In this article we will see how we can get the birth place of the person from the person object, imdb person object act similar to dictionary, therefore, getting place of birth from person object is similar from getting required information from the dictionary.

In order to do this we have to do the following –
1. Get the person object with the help of id by using get_person method 
2. Get the birth place from it using result[‘birth info’][‘birth place’] as keys 
3. Print the result 
 

Below is the implementation:

Python3




# importing the module
import imdb
 
# creating instance of IMDb
ia = imdb.IMDb()
 
# person id
code = "1372788"
 
# getting person object
actor = ia.get_person(code)
 
# printing object it prints its name
print(actor)
 
# getting birth place
place = actor['birth info']['birth place']
 
# printing the place
print(place)


Output :  

Shahid Kapoor
New Delhi, India

Another example:

Python3




# importing the module
import imdb
 
# creating instance of IMDb
ia = imdb.IMDb()
 
# person id
code = "1596350"
 
# getting person object
actor = ia.get_person(code)
 
# printing object it prints its name
print(actor)
 
# getting birth place
place = actor['birth info']['birth place']
 
# printing the place
print(place)


Output : 

Nawazuddin Siddiqui
Budhana, Muzaffarnagar, Uttar Pradesh, India

Thapelo Manthata
I’m a desktop support specialist transitioning into a SharePoint developer role by day and Software Engineering student by night. My superpowers include customer service, coding, the Microsoft office 365 suite including SharePoint and power platform.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments