[Tutor] how to extract time from datetime.date.time()

Kent Johnson kent37 at tds.net
Thu Nov 16 20:25:39 CET 2006


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.

Kent



More information about the Tutor mailing list