validators.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:validus 作者: shopnilsazal 项目源码 文件源码
def istime(value, fmt):
    """
    Return whether or not given value is valid time according to given format.
    If the value is valid time, this function returns ``True``, otherwise ``False``.

    Examples::

        >>> istime('30 Nov 00', '%d %b %y')
        True

        >>> istime('Friday', '%d')
        False

    :param value: string to validate time
    :param fmt: format of time
    """
    try:
        time_obj = time.strptime(value, fmt)
    except ValueError:
        return False
    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号