前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python日期时间格式化

Python日期时间格式化

作者头像
用户7886150
修改2021-01-19 10:21:01
2.4K0
修改2021-01-19 10:21:01
举报
文章被收录于专栏:bit哲学院bit哲学院

参考链接: Python日期时间

from datetime import datetime

update_stan = '18-11-07 10:10:10'

type(update_stan )

# output: <type 'str'>

# 字符串转为日期时间格式

update_str = datetime.strptime(update_stan, '%y-%m-%d %H:%M:%S')

update_str 

# output: datetime.datetime(2018, 11, 7, 10, 10, 10)

# 时间格式化为指定格式

update_date = update_str.strftime('%Y-%m-%d %H:%M:%S')

update_date

# output: '2018-11-07 10:10:10'

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档