📜  Python IMDbPY - 从搜索的名称中获取人名

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

Python IMDbPY - 从搜索的名称中获取人名

在本文中,我们将了解如何从搜索的姓名列表中获取人名,我们使用 search_name 方法查找所有相关的姓名。
search_name 方法返回列表,列表的每个元素都作为字典工作,即可以通过给出数据的键来查询它们,这里的键是名称。

下面是实现

Python3
# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# name of the person
name = "Nawazudin Siddiqui"
  
# searching the name of the person
search = ia.search_person(name)
 
# printing whole list
print(search)
 
# printing the name
for i in range(len(search)):
    print(search[i]['name'])


Python3
# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# name of the person
name = "Neil Nitin mukesh"
  
# searching the name of the person
search = ia.search_person(name)
 
# printing the name
for i in range(len(search)):
    print(search[i]['name'])


输出 :

[Person id:1596350[http] name:_Nawazuddin Siddiqui_]
Nawazuddin Siddiqui

另一个例子 :

Python3

# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# name of the person
name = "Neil Nitin mukesh"
  
# searching the name of the person
search = ia.search_person(name)
 
# printing the name
for i in range(len(search)):
    print(search[i]['name'])

输出 :

Neil Nitin Mukesh
Nitin Mukesh
Naman Nitin Mukesh
Nitin Mukesh