Date format without hour, minutes and seconds
本问题已经有最佳答案,请猛点这里访问。
我有以下代码:
1 2 3 4 | import datetime x = '2015-01-01' date = datetime.datetime.strptime(x,"%Y-%m-%d") print(date) |
问题是我想打印日期,像
1 2 3 4 5 6 | >>> import datetime >>> x = '2015-01-01' >>> date = datetime.datetime.strptime(x,"%Y-%m-%d") >>> print(date.date()) 2015-01-01 >>> |