将分钟转换为标准格式,可以通过整除获得小时,取余获得分钟

def time(**tim):
c = 0
for i in tim:
if int(i) <= 24 and int(i) >=0:
c = int(i) *60
if int(tim[i]) < 60 and int(tim[i]) >=0:
c += int(tim[i])
return ("转换后的总分钟为%d"%c)

hour = input("请输入小时")
mins = input("请输入分钟")
dict1 = {hour:mins}

if __name__ == "__main__":
print(time(**dict1))

def data(times):

if times <= 1440 and times >=0:
hour = int(((int(times)/60))) #取小时
minx = int(((int(times)%60))) #取分钟
if minx == 0: #如果分钟是0
return ("标准时间是%d:00"%(hour))
if minx != 0:
return ("标准时间是%d:%d"%(hour,minx))
if __name__ == "__main__":
print(data(500))
posted @ 2018-03-02 12:59  大明-两京一十三省  阅读(452)  评论(0编辑  收藏  举报