[英]How can I format this date into Day - Month - Year
def UpdateDate(WorstDate):
Day = WorstDate[5:]
Month = WorstDate[2:6]
Year = WorstDate[:2]
return Day + "-" + Month + "-" + Year
print(UpdateDate("202011Jan"))
I keep getting (1Jan-2011-20) I'm no pro so any advice would be appreciated.我不断收到 (1J-2011-20) 我不是专业人士,所以任何建议将不胜感激。
This might be useful:这可能有用:
import time
timestr = time.strftime("%d-%m-%Y")
print(timestr)
Below is the updated solution:以下是更新后的解决方案:
def UpdateDate(WorstDate):
Day = WorstDate[4:6]
Month = WorstDate[6:]
Year = WorstDate[:4]
return Day + "-" + Month + "-" + Year
print(UpdateDate("202011Jan"))
Output:输出:
11-Jan-2020
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.