Home python中string转换为datetime
Post
Cancel

python中string转换为datetime

python中将string转换为datetime类型比较简单。只要注意待转换字符串格式要跟正则表达式一致。另外还需要注意年月日的代表字母,比如年是%Y

1
2
3
from datetime import datetime
datetime_object = datetime.strptime('2018-04-26 11:30:00', '%Y-%m-%d %H:%M:%S')
print(type(datetime_object))

输出为:

1
<class 'datetime.datetime'>
This post is licensed under CC BY 4.0 by the author.

Ubuntu16.04下如何安装显卡驱动、cuda、cudnn

python中UnicodeDecodeError:'gb2312'codec can't decode bytes:illegal multibyte sequence解决办法