May-29-2022, 06:51 PM
I get the following error on line 4 when running the code below:
valueError: timedata '05/09/2022' does not match format '%m %d %Y'
I am trying to get a weekday value from 0-6 from a date represented in a string.
1 #!/usr/bin/env python3
2 import datetime
3 strdate = "05/29/2022"
4 day=datetime.datetime.strptime(strdate, "%m %d %Y").weekday()
5 print("weekday = ",day)
valueError: timedata '05/09/2022' does not match format '%m %d %Y'
I am trying to get a weekday value from 0-6 from a date represented in a string.
1 #!/usr/bin/env python3
2 import datetime
3 strdate = "05/29/2022"
4 day=datetime.datetime.strptime(strdate, "%m %d %Y").weekday()
5 print("weekday = ",day)