The date is out of range.
At that time, I used the datetime module to generate time format data, which was the result of misinformation of wrong parameters by hand. So, check the data well to solve the problem.
as follows:
# Convert string type data into time structure data # Originally wanted to write the following code import datetime date_init = ' 2019-05-10 00:00:00 ' date_end = datetime.datetime(int(date_init.split( ' - ' )[0]), int(date_init.split( ' - ' )[1]),int(date_init.split( ' - ' )[2]. split( ' ' )[0].lstrip(' 0 ')), int(date_init.split( ' - ' )[2].split( ' ' )[1].split( ' : ' )[0]) , int(date_init.split( ' - ' )[2].split( ' ' )[1].split( ' : ' )[1]), int(date_init.split( ' - ')[2].split( ' ' )[1].split( ' : ' )[2 ])) print date_end,type(date_end)
# Hand shake is wrong, as follows:
import datetime date_init = ' 2019-05-10 00:00:00 ' date_end = datetime.datetime(int(date_init.split( ' - ' )[0]), int(date_init.split( ' - ' )[1]),int(date_init.split( ' - ' )[2]. split( ' ' )[0].lstrip(' 1 ')), int(date_init.split( ' - ' )[2].split( ' ' )[1].split( ' : ' )[0]) , int(date_init.split( ' - ' )[2].split( ' ' )[1].split( ' : ' )[1]), int(date_init.split( ' - ')[2].split( ' ' )[1].split( ' : ' )[2 ])) print date_end,type(date_end)
Causes an error.
In fact, .lstrip(‘0’) can be omitted. At that time, it was considered wrong to add parameters to datetime.datetime(2019,05,05,00,00,00), so it was added.
end!
Similar Posts:
- ValueError: day is out of range for month [How to Solve]
- TypeError: Object of type ‘datetime‘ is not JSON serializable [Solved]
- [Solved] java.lang.IllegalArgumentException: Cannot format given Object as a Date
- [Solved] Python Error: datetime.datetime is not JSON serializable
- [Solved] scheduler Error: maximum number of running instances reached
- Python: __ new__ Method and the processing of typeerror: object() takes no parameters
- Using Vue + Axios: axios.post error: request failed with status code 400 is one of the solutions
- TypeError: strptime() argument 1 must be str, not bytes
- [Solved] Typeerror: incorrect padding occurred in python3 Base64 decoding
- C# String was not recognized as a valid DateTime [How to Solve]