我们用python获取当前周数时用到:

import time
print time.strftime("%W")

但是我最近发现获取的周数是要比实际周数少1周的,例如今天是41周,而python获取的是40周。

进入看源码,水平有限看不出什么东西,但是在这篇文章中找到了相关描述。

python获取周数与实际周数不一致

那就是说它有可能是从0开始算起,既然这样,给他+1就行了。

import time
# 获取今天是第几周
this_week = int(time.strftime('%W'))+1
print(this_week)

 

相关文章:

  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-02
  • 2021-12-04
  • 2022-12-23
相关资源
相似解决方案