python 实现UTC时间加减的方法

yipeiwu_com6年前Python基础

如下所示:

#!/usr/bin/env python
# -*- coding:utf-8 -*-
import datetime

time_delta = datetime.timedelta(hours=-2)
time_now = datetime.datetime.utcnow()
invalid_time = str(time_now + time_delta)[:19]

print invalid_time

以上这篇python 实现UTC时间加减的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python pip替换为阿里源的方法步骤

Python pip替换为阿里源的方法步骤

背景 由于 python 自带的源下载速度非常慢,特别是安装一些库的时候,甚至有时会失败。 pip国内的一些镜像   阿里云 http://mirror...

python 发送和接收ActiveMQ消息的实例

ActiveMQ是java开发的消息中间件服务。可以支持多种协议(AMQP,MQTT,OpenWire,Stomp),默认的是OpenWire。而python与ActiveMQ的通信使用...

用Python的urllib库提交WEB表单

复制代码 代码如下:class EntryDemo( Frame ): """Demonstrate Entrys and Event binding""" chosenrange =...

巧用Python装饰器 免去调用父类构造函数的麻烦

先看一段代码: 复制代码 代码如下: class T1(threading.Thread): def __init__(self, a, b, c): super(T1, self)._...

python之PyMongo使用总结

 PyMongo是什么 PyMongo是驱动程序,使python程序能够使用Mongodb数据库,使用python编写而成. 安装 环境:Ubuntu 14.04+pyt...