Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
请帮我将下面的字符串转换为日期类型。
130129:1007
[它的意思是2013/01/29 10:07am]
当我尝试将它写入我的数据库时,它给出了以下错误。DataError:日期/时间字段值超出范围:“130129:1007”
>>> from datetime import datetime >>> datetime.strptime('130129:1007', '%y%m%d:%H%M') datetime.datetime(2013, 1, 29, 10, 7)
看看datetime.strptime()。
datetime.strptime()