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
http://mail
Terry Carroll wrote:
> If you don't want the fractional part of the seconds, you can use the
> ordinary string methods to find the dot and slice off only the part you
> want to keep. For example:
>
s[0:s.find('.')]
> '10:56:04'
or s.split('.')[0] which you can put into your one-liner.
Ke
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, a
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
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 li
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'
> -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
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
htt