📜  Python IMDbPY - 获取人的出生地

📅  最后修改于: 2022-05-13 01:55:44.217000             🧑  作者: Mango

Python IMDbPY - 获取人的出生地

在本文中,我们将了解如何从 person 对象中获取人的出生地,imdb person 对象的行为类似于字典,因此,从 person 对象中获取出生地类似于从字典中获取所需信息。

下面是实现:

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)


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)


输出 :

Shahid Kapoor
New Delhi, India

另一个例子:

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)

输出 :

Nawazuddin Siddiqui
Budhana, Muzaffarnagar, Uttar Pradesh, India