+3 votes
in Programming Languages by (56.8k points)
How can I calculate the age of a person in days using Python code?

1 Answer

+2 votes
by (74.2k points)
selected by
 
Best answer

The datetime module supplies classes for manipulating dates and times. You can use the date class of this module to compute the age in days.

Here is an example:

from datetime import date

currentdate = date.today()

birthday = date(1988, 11, 10)

age = currentdate - birthday

print(age.days)


...