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
评论列表
文章目录