python判断给定的字符串是否是有效日期的方法
作者:dingding 时间:2023-04-07 20:07:07
本文实例讲述了python判断给定的字符串是否是有效日期的方法。分享给大家供大家参考。具体分析如下:
这里python判断给定的字符串是否是一个有效的日期,如果是一个日期格式的字符串,该函数返回True,否则返回False
def is_valid_date(str):
'''判断是否是一个有效的日期字符串'''
try:
time.strptime(str, "%Y-%m-%d")
return True
except:
return False
希望本文所述对大家的Python程序设计有所帮助。
标签:python,字符串,日期
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python基于yaml文件配置logging日志过程解析
2022-04-02 10:50:36
keras.layers.Conv2D()函数参数用法及说明
2022-02-25 01:15:05
python的描述符(descriptor)、装饰器(property)造成的一个无限递归问题分享
2023-04-29 08:57:32
thinkphp实现图片上传功能分享
2024-05-22 10:06:36
Python pathlib模块实例详解
2023-03-10 10:59:06
python用tkinter开发的扫雷游戏
2022-05-16 18:39:40
![](https://img.aspxhome.com/file/2023/8/84978_0s.png)
ASP存储过程开发应用详解第1/2页
2011-04-07 11:16:00
Jmeter HTTPS接口测试证书导入过程图解
2021-11-19 18:34:36
![](https://img.aspxhome.com/file/2023/8/135028_0s.png)
开启MySQL的binlog日志的方法步骤
2024-01-29 07:31:25
![](https://img.aspxhome.com/file/2023/3/105483_0s.png)
python实现员工管理系统
2022-01-03 05:20:15
![](https://img.aspxhome.com/file/2023/1/82801_0s.png)
Go学习笔记之Zap日志的使用
2023-09-19 01:21:36
java URL 获取PHP JSON 数据
2023-11-14 18:02:02
详解ES6之async+await 同步/异步方案
2023-08-24 11:10:54
Python决策树之基于信息增益的特征选择示例
2023-01-09 23:44:32
![](https://img.aspxhome.com/file/2023/0/101290_0s.png)
python实现简单中文词频统计示例
2022-04-17 16:54:35
![](https://img.aspxhome.com/file/2023/7/101557_0s.png)
SQL Server 2005如何设置多字段做关键字
2009-01-08 15:57:00
使用C#配合ArcGIS Engine进行地理信息系统开发
2023-06-25 16:35:01
![](https://img.aspxhome.com/file/2023/6/61966_0s.jpg)
dataframe设置两个条件取值的实例
2021-09-15 05:56:50
Python图片批量自动抠图去背景的代码详解
2022-11-30 17:20:39
![](https://img.aspxhome.com/file/2023/2/131192_0s.jpg)
PYTHON基础-时间日期处理小结
2023-04-23 02:02:59