I would like to ask about string conversion of dates including English month in python.
date:10 OCT 2017
This is a character type, so I would like to convert it to a date type.
from datetime import datetime
datetime.strptime('date', '%d%b%Y')
I am trying to convert in , but I cannot because of an error.
I would appreciate it if someone could let me know.
Thank you for your cooperation.
In your Python 3.6.1 environment, the following coding seems to work well.
If the first argument of datetime.strptime('date','%d%b%Y')
really remains 'date'
, it is treated as a string of atedate と instead of a variable.
Alternatively, :
of the code provided is a full-width character, so is this mistaken for a half-width character?
If the code below does not solve this problem, it will be easier to get a more detailed answer if you add the error as it is.
>>>from datetime import datetime
>>>date="10 OCT 2017"
>> datetime.strptime (date, '%d%b%Y')
datetime.datetime (2017, 10, 10, 0, 0)
>>>date="date:10 OCT 2017"
>> datetime.strptime (date, 'date: %d %b %Y')
datetime.datetime (2017, 10, 10, 0, 0)
365 FileNotFoundError in json: What is the difference between these two?
354 JSON.parse fails even though there is no problem with the format.
352 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
356 I want to change the format (date and time display) of the legend in chronological order.
© 2023 OneMinuteCode. All rights reserved.