Python localtime()方法计算今天是一年中第几周,pythonlocaltime,Python local


Python localtime()方法计算今天是一年中第几周,需要先导入time模块,之后用localtime()方法来计算。Python的localtime()方法作用是格式化时间戳为本地的时间,话不多说,还是来看看Python如何来计算今天是本年第几周的Python源码吧。

Python计算时间与日期的其他相关文章推荐:
(1)Pythno计算过去了多少个周末
(2)用Python编写的一个计算生肖和星座的函数代码

Python语言:计算今天是一年中的第几周方法源码如下:

#! /usr/bin/env python#coding=utf-8import timeprint u"今天是今年的第",print time.localtime()[7]/7+1,print u"周"

是不是没想到这个Python的源码这么短小,但却是能解决问题。

编橙之家文章,

评论关闭