In import datetime, enter datetime.strptime() year 5 digits

Asked 2 years ago, Updated 2 years ago, 19 views


from datetime import datetime,timedelta
a = input()
(b,c,d) = a.split()
e = int(b)
f = int(c)
g = int(d)

today = datetime(e,f,g)
tomorrow = today + timedelta(days=1)
s = tomorrow.strftime("%Y%m%d")


In this code, if the value of e is a four-digit number, it can be taken as %Y and processed If it's a 5-digit number, is there any way to get the value and deal with it? I'd appreciate it if you let me know.

python

2022-09-22 15:09

1 Answers

Suppose that e can be 5 digits, drink . According to Python datetime official document , MAXYEAR is 99999.


2022-09-22 15:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.