Hi,
I want to extract hh:mm:ss from below mentioned code:
import datetime
t = datetime.datetime.now()
print t
2006-11-16 16:59:02.843000
How to do it?
TIA.
Regards,
Asrarahmed
--
To HIM you shall return.
___
Tutor maillist - Tutor@python.org
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Asrarahmed Kadri
Sent: Thursday, November 16, 2006 10:29 AM
To: tutor-python
Subject: [Tutor] how to extract time from datetime.date.time()
Hi,
I want to extract hh:mm:ss from below mentioned
How about two different ways:
import datetime
t = datetime.datetime.now()
t
datetime.datetime(2006, 11, 16, 11, 28, 15, 75)
t.hour
11
t.minute
28
t.second
15
a = %d:%d:%d % (t.hour,t.minute,t.second)
a
'11:28:15'
or, a bit more succinctly:
t.strftime('%H:%M:%S')
'11:28:15'
Asrarahmed Kadri wrote:
Hi,
I want to extract hh:mm:ss from below mentioned code:
import datetime
t = datetime.datetime.now()
print t
2006-11-16 16:59:02.843000
How to do it?
Did you read the documentation and try something out before posting this
question on the list?
--
On Thu, 2006-11-16 at 17:28 +, Asrarahmed Kadri wrote:
Hi,
I want to extract hh:mm:ss from below mentioned code:
import datetime
t = datetime.datetime.now()
print t
2006-11-16 16:59:02.843000
How to do it?
The python interpreter can be pretty helpful for this kind of
On Thu, 16 Nov 2006, Asrarahmed Kadri wrote:
I want to extract hh:mm:ss from below mentioned code:
import datetime
t = datetime.datetime.now()
print t
2006-11-16 16:59:02.843000
How to do it?
In addition to the suggestions you've seen, now() returns a datetime
object, and a datetime
On Thu, 16 Nov 2006, Kent Johnson wrote:
or s.split('.')[0] which you can put into your one-liner.
Yes, but that would not have given me the opportunity to write that
extravagantly run-on sentence.
___
Tutor maillist - Tutor@python.org