擅长:python、mysql、java
<p>重构代码</p>
<pre><code>from imdb import IMDb
ia = IMDb()
def getmovieID(movie_name):
movie = ia.search_movie(movie_name)[0]
get_movie = ia.get_movie(movie.movieID)
return get_movie
def getcast(movie_name):
movie = getmovieID(movie_name)
casts_objects = movie.get('cast')
casts = []
for person in casts_objects:
casts.append(person.get('name'))
return casts
print(getcast('The Dark Knight'))
</code></pre>