如何使用Python计算两个日期之间的天数?

如何使用Python计算两个日期之间的天数?,python,django,python-datetime,Python,Django,Python Datetime,我想使用Python Django计算两个日期之间的天数。这是我的密码 在我的Html中 <form method='post' action="something"> <input type="date" name="firstdate"> <input type="date" " name="lastdate"> <input

我想使用Python Django计算两个日期之间的天数。这是我的密码

在我的Html中

<form method='post' action="something">
  <input type="date"  name="firstdate">
  <input type="date" " name="lastdate">
  <input type="submit">
</form>

我想计算这两个日期之间的天数。怎么做?如果有人能帮我解决这个问题,我将不胜感激。

假设d0为2020-01-01,d1为2020-02-01

delta = d1 - d0
print(delta.days)

这回答了你的问题吗?
delta = d1 - d0
print(delta.days)