Printing just the time and no date from time.ctime()?

import time

time = (time.ctime())

prints out

“Tue Mar 1 12:43:53 2016”

Is there anyway to print JUST the “12:43:53” section of this statement?

EDIT: Solved

from time import strftimestrftime("%m/%d/%Y %H:%M")


Used this instead.

Afaik ctime() doesn’t offer any formatting options. You could use localtime() instead. It returns a struct which then can be formatted with strftime():

t = time.localtime()
print(time.strftime('%H:%M:%S', t))

import datetime
datetime.time(now.hour, now.minute, now.second
datetime.time(11,23, 44 )

happy bl