Python IMDbPY – 信息设置为电影对象的键
在本文中,我们将看到如何将信息集转换为键,我们可以通过get_movie_infoset
知道电影的信息集,但是即使在获取信息集后我们也无法像字典一样使用。
为了将信息集用作字典键,我们必须使用infoset2keys
方法。
Syntax : movie.infoset2keys
Here movie is the imdb Movie object
Action performed : This will allow info set to use as dictionary keys
下面是实现
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# ID
code = "0094226"
# searching the Id and getting info set
movie = ia.get_movie(code, info =['taglines', 'plot'])
# making infoset to use as keys
movie.infoset2keys
# printing movie tagline
print(movie['taglines'])
输出 :
[‘The Chicago Dream is that big’, ‘No one messed with Al Capone, but Eliot Ness messed with him’, “AL CAPONE. He ruled Chicago with absolute power. No one could touch him. No one could stop him. – Until Eliot Ness and a small force of men swore they’d bring him down.”, ‘What are you prepared to do?’, ‘Never stop fighting till the fight is done’]
另一个例子
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# ID
code = "4434004"
# searching the Id and getting info set
movie = ia.get_movie(code, info =['plot'])
# making infoset to use as keys
movie.infoset2keys
# printing movie plot
print(movie['plot'])
输出 :
[‘A story that revolves around drug abuse in the affluent north Indian State of Punjab and how the youth there have succumbed to it en-masse resulting in a socio-economic decline.’, “What on earth can a rock star, a migrant laborer, a doctor and a cop possibly have in common? Simple, Punjab! 4 lives, 1 connection – ‘Udta Punjab’ takes you on a trip like never before. Shahid Kapoor, Kareena Kapoor, Alia Bhatt and Diljit Dosanjh play characters from different walks of life, fighting the menace of drugs in their own way. The film journeys into the artificial highs and the real lows that they face while treading the paths fraught with mortal dangers. But above all, Udta Punjab is about the famed Punjabi spirit, that despite being fully down, has the audacity of looking you in the eye and saying – Drugs di maa di!”]