I have dates MMDDYY, that is today111609
MMDDYY
111609
How do I convert this to 11/16/2009, in Python?
11/16/2009
I suggest the following:
import datetime date = datetime.datetime.strptime("111609", "%m%d%y") print date.strftime("%m/%d/%Y")
It converts 010199to 01/01/1999and 010109to 01/01/2009.
010199
01/01/1999
010109
01/01/2009
date = '111609' new_date = date[0:2] + '/' + date[2:4] + '/' + date[4:6]
>>> s = '111609' >>> d = datetime.date(int('20' + s[4:6]), int(s[0:2]), int(s[2:4])) >>> # or, alternatively (and better!), as initially shown here, by Tim >>> # d = datetime.datetime.strptime(s, "%m%d%y") >>> d.strftime('%m/%d/%Y') '11/16/2009'
, strptime(), , , , , 20- 21- .
,
date_var = ("11/16/2009") datetime.date.replace(year=2009, month=11, day=16)
Source: https://habr.com/ru/post/1723041/More articles:HttpWebRequest.EndGetRequestStream issue in Silverlight - c #responsive server-side api analytics - restCombine JavaScript objects - javascriptSetting up the WYSIWYG editor for users of the Drupal site - drupalкак можно использовать тип данных PL/SQL BINARY_INTEGER как типы Java? - javassl в форме входа? - sslGetting a member through a string in C #? - c #Ruby: преобразовать кодированный символ в действительный символ UTF-8 - rubyUsing Elma with Cassini - asp.netHow does the .NET process get culture information? - c #All Articles