If I have two dates (ex. '8/18/2008'
and '9/26/2008'
), what is the best way to get the number of days between these two dates?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
without using Lib just pure code:
For calculating dates and times there are several options but I will write the simple way:
Hope it helps
You want the datetime module.
Or other example:
As pointed out here
It also can be easily done with
arrow
:For reference: http://arrow.readthedocs.io/en/latest/
Here are three ways to go with this problem :
This assumes, of course, that you've already verified that your dates are in the format
r'\d+/\d+/\d+'
.