Formatting time in Python? -
how go formatting time in python?
lets have
time = 9.122491
the time in hours , need convert h:m format. desired output should be:
9:07
any appreciated!
using datetime
module:
>>> datetime import datetime, timedelta >>> mytime = 9.122491 >>> temp = timedelta(hours=mytime) >>> print((datetime(1, 1, 1) + temp).strftime('%h:%m')) 09:07
Comments
Post a Comment