本文整理匯總了Python中movie.Movie.read_movie_file方法的典型用法代碼示例。如果您正苦於以下問題:Python Movie.read_movie_file方法的具體用法?Python Movie.read_movie_file怎麽用?Python Movie.read_movie_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類movie.Movie
的用法示例。
在下文中一共展示了Movie.read_movie_file方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_top_movies
# 需要導入模塊: from movie import Movie [as 別名]
# 或者: from movie.Movie import read_movie_file [as 別名]
def get_top_movies(self, top_x, min_ratings):
movie_rows_list = Movie.read_movie_file()
movie_list_with_min_ratings = []
for movie in movie_rows_list:
movie_id = movie[0]
movie_name = movie[1]
ratings_list = self.get_movie_rating_list(movie_id)
# print("movie_id", movie_id)
# print("ratings", ratings_list)
if len(ratings_list) >= min_ratings:
movie_avg_tup = (movie_id, movie_name, self.get_avg_rating(movie_id))
movie_list_with_min_ratings.append(movie_avg_tup)
sorted_list = sorted(movie_list_with_min_ratings, key = lambda x: x[2])
reversed_list = list(reversed(sorted_list))
# print(sorted_list)
# print(reversed_list)
top_x_list = reversed_list[:top_x]
#print(top_x_list)
return top_x_list