Python IMDbPY – 信息设置为 Person 对象的键
在本文中,我们将看到如何将信息集转换为键,我们可以通过get_person_infoset
知道电影的信息集,但是即使在获取信息集后我们也无法像字典一样使用。
为了将信息集用作字典键,我们必须使用infoset2keys
方法。
Syntax : person.infoset2keys
Here movie is the imdb Person 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 = "4731677"
# searching the Id and getting info set
person = ia.get_person(code, info =['biography'])
# making infoset to use as keys
person.infoset2keys
# printing bio graphy
print(person['biography'])
输出 :
[‘Ayushmann Khurrana was born on 14 September 1984 in Chandigarh, India. Ayushmann started off his career as a popular radio jockey, and eventually became a VJ on MTV India and one of the most popular hosts in India. He shot to stardom with the runaway hit, \’Vicky Donor\’ in 2012. His effortless act in his debut won him rave reviews and the film went on to become one of the biggest hits of the year. The quirky film coupled with some fabulous songs, especially \’Paani da\’ (sung & co-composed by Khurrana) marked his arrival in the Hindi film industry. He also won a slew of highly prestigious awards in 2012.A native of Punjab, Ayushmann studied at St. John\’s High School and DAV College in Chandigarh. He majored in English literature and has a master\’s degree in Mass Communication from School of Communication Studies, Punjab University, in Chandigarh. He did serious theatre for five years. He was also the founder member of DAV College\’s “Aaghaaz” and “Manchtantra”, which are active theatre groups in Chandigarh. He has conceptualized and acted in street plays, and won prizes in national college festivals like Mood Indigo (IIT Bombay), Oasis (Birla Institute of Technology and Science, Pilani) and St. Bedes Simla. He also won a Best Actor award for playing Ashwatthama in Dharamvir Bharati\’s Andha Yug.From theatre to television to the big screen, Ayushmann\’s progression as an artist has been one of the most organic ones. He followed up his Vicky Donor act with some films where his performances were highly appreciated by the audience and critics alike. Ayushmann simultaneously built his oeuvre as a singer and live performer as well. His three singles – \’O Heeriye, \’ \’Mitti Di Khushboo, \’ and the latest, \’Yahin Hoon Main\’ – have won millions of hearts.::Nishanth’]
另一个例子
# importing the module
import imdb
# creating instance of IMDb
ia = imdb.IMDb()
# ID
code = "2690647"
# searching the Id and getting info set
person = ia.get_person(code, info =['filmography'])
# making infoset to use as keys
person.infoset2keys
# printing filmo graphy
print(person['filmography'])
输出 :
[{'actor': [Movie id:11261278[http] title:_Romeo (2020)_.......(2018)_]}]