问题:
This is my code: 这是我的代码:
import datetime
today = datetime.date.today()
print today
This prints: 2008-11-22
which is exactly what I want. 打印: 2008-11-22
这正是我想要的。
But, I have a list I'm appending this to and then suddenly everything goes "wonky". 但是,我有一个列表要附加到该列表中,然后突然所有内容都变得“异常”。 Here is the code: 这是代码:
import datetime
mylist = []
today = datetime.date.today()
mylist.append(today)
print mylist
This prints the following: 打印以下内容:
[datetime.date(2008, 11, 22)]
How can I get just a simple date like 2008-11-22
? 我怎样才能得到像2008-11-22
这样的简单约会?
解决方案:
参考一: https://stackoom.com/question/1J4F/如何以常规格式打印日期参考二: https://oldbug.net/q/1J4F/How-to-print-a-date-in-a-regular-format
来源:oschina
链接:https://my.oschina.net/u/4438370/blog/4358816