Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 确定周数_Python - Fatal编程技术网

Python 确定周数

Python 确定周数,python,Python,我有今天的日期和日期(例如,2010-06-25)。所以 然后我需要找到从过去到现在的周数(int)。请解释一下,我是通过timedelta完成的,但它不起作用。 谢谢 from datetime import datetime, time, date today = date.today() year_past = 2010 past = datetime.strptime('25-06-'+str(year_past), '%d-%m-%Y') from datetime import d

我有今天的日期和日期(例如,2010-06-25)。所以

然后我需要找到从过去到现在的周数(int)。请解释一下,我是通过timedelta完成的,但它不起作用。 谢谢

from datetime import datetime, time, date
today = date.today()
year_past = 2010
past = datetime.strptime('25-06-'+str(year_past), '%d-%m-%Y')
from datetime import date
today = date.today()
delta = today - date(2010,6,25)
delta.days / 7
# out: 138