Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我被这个python问题困住了,我有一个月-日-年格式的日期,我需要将其更改为年-月-日格式
>>> import datetime >>> datetime.datetime.strptime("06/03/2015", "%m/%d/%Y").strftime("%Y-%m-%d") '2015-06-03'
这将日期(在本例中为 2015 年 6 月 3 日)作为字符串,并使用strptime. 然后它使用您请求的格式(YYYY-mm-dd)将其转换为字符串strftime
strptime
strftime