【发布时间】:2019-09-17 20:24:40
【问题描述】:
我正在尝试使用 Python time 模块生成周数字符串,考虑到一周从 Sunday 开始。
如果我对官方documentation的解释是正确的,那么可以通过以下代码实现:
import time
time.strftime("%U", time.localtime())
>> 37
我的问题是,上面的输出正确吗?考虑到以下细节,输出不应该是 38:
我的时区是 IST (GMT+5:30)
import time
#Year
time.localtime()[0]
>> 2019
#Month
time.localtime()[1]
>> 9
#Day
time.localtime()[2]
>> 18
【问题讨论】:
标签: python time week-number