Python 将一个已知的utc时间转换为东八区时间,pythonutc,我们先获取一个utc
Python 将一个已知的utc时间转换为东八区时间,pythonutc,我们先获取一个utc
我们先获取一个utc时间
time_utc = datetime.datetime.utcnow()print(time_utc)
输出
2018-06-24T08:59:39.338355
将这个已知的utc时间转换为东八区的时间
time_now = (time_utc + datetime.timedelta(hours=8))print(time_now)
输出
2018-06-24 16:59:39.338355
转换完成, 可以使用strftime()方法将其进行格式化
Python 将一个已知的utc时间转换为东八区时间
相关内容
- Python—字符串+变量,python字符串变量,字符串转义字符
- python time包中的time.time()和time.clock()的区别,,在统计p
- Python面向对象(一)—类和对象,python面向对象对象
- python之协程,python, 一、这几天在折腾
- Python中通过lambda抛异常的奇迹淫巧,,假设我们需要一个
- python-选课系统,,详细要求:1、创建北
- python生成动态个性二维码,,1 安装工具2 生成
- python 3 之日期与时间处理模块(date和datetime),,前言相
- Python语言importError:cannot import name 'InvalidArgumentEx
- python-数据结构代码 图(邻接表),,class Vert
评论关闭