def display_movie_length(seconds):
# the // ensures you are using integer division
# You can also use / in python 2.x
hours = seconds // 3600
# You need to understand how the modulo operator works
rest_of_seconds = seconds % 3600
# I'm sure you can figure out what to do with all those leftover seconds
minutes = minutes_from_seconds(rest_of_seconds)
return "%d:%02d" % (hours, minutes)
那么镜头在电影里的秒数是多少?那是个坏名字。Python已经使用len这个词来表示其他东西了。改变它。
你只需要弄清楚
minutes\_from\_seconds()
应该是什么样子。如果你还不清楚,那就研究一下模算符。你可以使用timedelta
或者,对于较新版本的Python:
相关问题 更多 >
编程相关推荐