samedi 23 juillet 2016

How to print date in a regular format in Python?

This is my code:

import datetime
today = datetime.date.today()
print today

This prints: 2008-11-22 which is exactly what I want 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 on earth can I get just a simple date like "2008-11-22"?

Aucun commentaire:

Enregistrer un commentaire