我是Python的初学者,所以我真的不知道很多术语或任何东西。我可以询问如何将分钟转换为小时和分钟 EX:75分钟 - > 0天,1小时,15分钟
print('Welcome to the Scheduler!')
print('What is your name?')
name = input()
print= ('How many chocolates are there in the order?')
chocolates = input()
print = ('How many chocolate cakes are there in the order?')
chocolate_cakes = input()
print = ('How many chocolate ice creams are in the order?')
chocolate_ice_creams = input()
total_time = float(chocolates) + float(chocolate_cakes) + float(chocolate_ice_creams)
print = ('Total Time:' )
print = ('How many minutes do you have before the order is due?')
minutes = input()
extra_time = float(minutes) - float(total_time)
print = ('Your extra time for this order is', extra_time )
time = extra_time // 60
print('Thank you,' , name)
答案 0 :(得分:1)
如果你在几分钟内给出一个大于等于1440分钟的输入,那么你至少有一天。因此,为了处理这个问题(以及时间的其他方面),我们可以使用模数(%)。
java.util.zip.ZipException
这应该有用。
答案 1 :(得分:0)
from datetime import datetime
day = minutes = hours = 0
day = datetime.now ()
day = day.day
minutes = datetime.now ()
minutes = minutes.minute
hours = datetime.now ()
hours = hours.hour
print ("It's day" + str (day) + "and it's" + str (minutes) + "minutes and" + str (hours) + "hours.")
答案 2 :(得分:0)
上面的这段代码不起作用我开始制作我自己的版本,这个代码如何帮助你记住我是一个业余爱好者是真的
from datetime import datetime
day = minutes = hours = 0
time = datetime.now().minute
days = time / 1440
leftover_minutes = time % 1440
hours = leftover_minutes / 60
mins = time - (days*1440) - (hours*60)
print(str(days) + " days, " + str(hours) + " hours, " + str(mins) + " mins. ")
答案 3 :(得分:0)
为了得到整数,你实际上必须四舍五入。
import math
def transform_minutes(total_minutes):
days = math.floor(total_minutes / (24*60))
leftover_minutes = total_minutes % (24*60)
hours = math.floor(leftover_minutes / 60)
mins = total_minutes - (days*1440) - (hours*60)
#out format = "days-hours:minutes:seconds"
out = '{}-{}:{}:00'.format(days, hours, mins)
return out
答案 4 :(得分:-1)
# Python Program to Convert seconds
# into hours, minutes and seconds
def convert(seconds):
seconds = seconds % (24 * 3600)
hour = seconds // 3600
seconds %= 3600
minutes = seconds // 60
seconds %= 60
return "%d:%02d:%02d" % (hour, minutes, seconds)
# Driver program
n = 12345
print(convert(n))
method = a
import datetime
str(datetime.timedelta(seconds=666))
'0:11:06'
method = b
def convert(seconds):
seconds = seconds % (24 * 3600)
hour = seconds // 3600
seconds %= 3600
minutes = seconds // 60
seconds %= 60
return "%d:%02d:%02d" % (hour, minutes, seconds)