python时区设置的两种方式

        第一种用pytz

 

        第二种手动加时区再转换格式

      a = datetime.datetime.today()

o = datetime.timedelta(hours=8)

      (a+o).strftime("%Y-%m-%d_%H:%M")

    

     转化后效果   test_admin_stable_2016-04-18_21:21.tar.gz

    

 

       如果你的程序要考虑时区,可以使用pytz。datetime模块中有tzinfo相关的东西,个抽象类,文档上说:


tzinfo is an abstract base clase, meaning that this class should not be instantiated directly. You need to derive a concrete subclass, and (at least) supply implementations of the standard tzinfo methods needed by thedatetime methods you use. The datetime module does not supply any concrete subclasses of tzinfo

上面是说tzinfo是一个抽象类,不应该被直接实例化。你需要派生子类,提供相应的标准方法。datetime模块并不提供tzinfo的任何子类。

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值