def str2dt(s):
    """Works with time with/without seconds."""
    return datetime.datetime.strptime(s, _FMTS if s.count(":") == 2 else _FMT if s.count(":") == 1 else _FMT0)
def str2dt ( s ) : return datetime . datetime . strptime ( s , _FMTS if s . count ( ":" ) == 2 else _FMT if s . count ( ":" ) == 1 else _FMT0 )
Works with time with/without seconds.