我目前正在使用Python连接到一个数据库
在其中一个表中,date的格式是:2019/03/02
(%Y-%m-%d
)
在Python文件中,我有:
startdate=datetime.strptime(request.form[('startdate')],'%Y-%m-%d')
enddate = datetime.strptime(request.form[('enddate')],'%Y-%m-%d')
在网页中,添加日期:2018/03/02
作为startdate
和2019/03/02
作为enddate
时,出现错误:
timedata 2018/03/02 does not match format ('%Y-%m-%d').
datetime
模块是用python导入的
因此,有人能解释一下如何修复这个错误吗
必须使用与数据匹配的格式
正如the documentation所说:
没有
%
前缀的字符与其自身匹配所以正确的格式应该是
%Y/%m/%d
相关问题 更多 >
编程相关推荐