How about two different ways:<br><br>>>> import datetime<br>>>> t = datetime.datetime.now()<br>>>> t<br>datetime.datetime(2006, 11, 16, 11, 28, 15, 750000)<br>>>> t.hour<br>11<br>>>>
t.minute<br>28<br>>>> t.second<br>15<br>>>> a = "%d:%d:%d" % (t.hour,t.minute,t.second)<br>>>> a<br>'11:28:15'<br>>>> <br><br>or, a bit more succinctly:<br><br>>>> t.strftime
('%H:%M:%S')<br>'11:28:15'<br><br>All of this info is readily avaliable in the python docs.<br><br><a href="http://docs.python.org/lib/module-datetime.html">http://docs.python.org/lib/module-datetime.html</a><br><br><br><div>
<span class="gmail_quote">On 11/16/06, <b class="gmail_sendername">Asrarahmed Kadri</b> <<a href="mailto:ajkadri@googlemail.com">ajkadri@googlemail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>Hi,</div>
<div> </div>
<div>I want to extract hh:mm:ss from below mentioned code:</div>
<div> </div>
<div>import datetime<br>>>> t = datetime.datetime.now()<br>>>> print t<br>2006-11-16 16:59:02.843000</div>
<div> </div>
<div>How to do it?</div>
<div> </div>
<div>TIA.</div>
<div>Regards,</div>
<div>Asrarahmed<br clear="all"><br>-- <br>To HIM you shall return. </div>
<br>_______________________________________________<br>Tutor maillist - <a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:Tutor@python.org">Tutor@python.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">
http://mail.python.org/mailman/listinfo/tutor</a><br><br><br></blockquote></div><br>