1 2 3 4 5 6 7 8 9 10
| rest = 277532.5234
conv = (31536000,2592000,86400,3600,60,1,0.001)
result = [0,0,0,0,0,0,0]
i=0
while rest>0 and i<=6 :
result[i], rest = divmod(rest,conv[i] )
i+=1
duree = str(int(result[0])) + " année(s), " + str(int(result[1])) + " mois, " + str(int(result[2])) + " jour(s), " + str(int(result[3])) + " heure(s), " + str(int(result[4])) + " minute(s), " + str(int(result[5])) + " seconde(s), " + str(int(result[6])) + " millisecondes"
print ("Durée en années, mois, jours, minutes, secondes, millisecondes : ", duree) |
Partager