📌  相关文章
📜  Python IMDbPY - 检查人是否是电影的一部分

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

Python IMDbPY - 检查人是否是电影的一部分

在本文中,我们将了解如何检查某个人是否是电影的一部分,很多人都在制作电影,有时我们不知道一个人是否在那部电影中,但是使用我们可以检查运算符的帮助in

下面是实现

# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# ID
code = "4434004"
  
# getting movie
movie = ia.get_movie(code)
  
# person id
code2 = "1372788"
  
# getting person
person = ia.get_person(code2)
  
# printing movie object
print(movie)
  
# printing person object
print(person)
  
print("===============")
  
# checking if person is in the movie or not
if person in movie:
    print("Yes !!")
      
else:
    print("No !!")

输出 :

Udta Punjab
Shahid Kapoor
===============
Yes!!

另一个例子

# importing the module
import imdb
  
# creating instance of IMDb
ia = imdb.IMDb()
  
# ID
code = "1187043"
  
# getting movie
movie = ia.get_movie(code)
  
# person id
code2 = "1372788"
  
# getting person
person = ia.get_person(code2)
  
# printing movie object
print(movie)
  
# printing person object
print(person)
  
print("===============")
  
# checking if person is in the movie or not
if person in movie:
    print("Yes !!")
      
else:
    print("No !!")

输出 :

3 Idiots
Shahid Kapoor
===============
No!!