[Tutor] Converting "HH:MM:SS" to datetime

Kent Johnson kent37 at tds.net
Sun Mar 1 22:18:04 CET 2009


On Sun, Mar 1, 2009 at 3:51 PM, Wayne Watson
<sierra_mtnview at sbcglobal.net> wrote:
>         x = str(self.start_time)
>         set_loc_dict["start_time"] =
> datetime.datetime.strptime(x,"%H:%M:%S")
>
> It seems like there should be a simpler way to wrestle this to datetime.

You say self.start_time is a str, so there is no need to convert it,
and no need for the helper variable. How about
set_loc_dict["start_time"] =
datetime.datetime.strptime(self.start_time,"%H:%M:%S")

Kent


More information about the Tutor mailing list