Last active
January 8, 2020 14:25
-
-
Save etigui/98c4699ed51f2a237479960ed15080a8 to your computer and use it in GitHub Desktop.
Appending to list in Python dictionary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
dico = dict() | |
dico.setdefault('42', []).append(datetime.now().strftime("%d-%m-%Y %H:%M:%S:%f")) | |
dico.setdefault('42', []).append(datetime.now().strftime("%d-%m-%Y %H:%M:%S:%f")) | |
dico.setdefault('777', []).append(datetime.now().strftime("%d-%m-%Y %H:%M:%S:%f")) | |
dico.setdefault('777', []).append(datetime.now().strftime("%d-%m-%Y %H:%M:%S:%f")) | |
print(dico) | |
## Output ## | |
# {'42': ['08-01-2020 15:23:18:424524', '08-01-2020 15:23:18:424539'], | |
# '777': ['08-01-2020 15:23:18:424543', '08-01-2020 15:23:18:424545']} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment