本文整理匯總了Python中movie.Movie.read_movies_from_file方法的典型用法代碼示例。如果您正苦於以下問題:Python Movie.read_movies_from_file方法的具體用法?Python Movie.read_movies_from_file怎麽用?Python Movie.read_movies_from_file使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類movie.Movie
的用法示例。
在下文中一共展示了Movie.read_movies_from_file方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: find_movie
# 需要導入模塊: from movie import Movie [as 別名]
# 或者: from movie.Movie import read_movies_from_file [as 別名]
def find_movie(self,user_action):
self.header_output("Finding....")
print "\n Example: find iron or find Iron Man 3 \n"
movies = Movie.read_movies_from_file()
if user_action != []:
arg = user_action.pop(0)
found = [x for x in movies if self.search(x,arg)]
self.movie_table_output(found)
示例2: list_movie
# 需要導入模塊: from movie import Movie [as 別名]
# 或者: from movie.Movie import read_movies_from_file [as 別名]
def list_movie(self,kwargs):
print "\n Example: list name, list rating, list date or list by name etc. \n"
sort_order = 'name'
if kwargs != []:
if kwargs[0] == 'by':
sort_order = kwargs.pop(1)
else:
sort_order = kwargs.pop(0)
movies = Movie.read_movies_from_file()
if sort_order == 'date':
movies.sort(cmp = lambda x, y: cmp(x.date, y.date))
elif sort_order == 'rating':
movies.sort(cmp = lambda x, y: cmp(x.rating, y.rating))
else:
movies.sort(cmp = lambda x, y: cmp(x.movie, y.movie))
self.movie_table_output(movies)