【发布时间】:2019-03-08 07:59:10
【问题描述】:
我有一个time.strptime的python代码,格式如下:
start_date = time.strptime('2019-03-25', '%Y-%m-%d')
但是现在如果我的用户尝试输入不符合格式的时间会报错。
假设用户尝试这样输入日期格式:
start_date = time.strptime('25-03-2019', '%Y-%m-%d')
这会给出错误信息
ValueError: time data '25-03-2019' does not match format '%Y-%m-%d'
那么,如何对字符串进行编码以自动赋予服务器提供的格式..?
【问题讨论】:
标签: python python-3.x encoding decode