def strptime(string, fmt):
    'Parse a time string to datetime.'
    try:
        return datetime.strptime(string, fmt)
    except (ValueError, AttributeError, TypeError):
        return string
Parse a time string to datetime.
def strptime(string, fmt):
    
    try:
        return datetime.strptime(string, fmt)
    except (ValueError, AttributeError, TypeError):
        return string