Cette page n'est pas encore disponible en français, sa traduction est en cours. Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.
Metadata
ID:python-best-practices/no-datetime-today
Language: Python
Severity: Notice
Category: Best Practices
Description
Avoid using datetime.today() and use instead datetime.now(). The two calls are equivalent (as mentioned in the official documentation) and the use of now() is more explicit than today().
Using today() makes you think it only returns the year/month/day but it returns a full timestamp. For this reason, prefer using now().
Non-Compliant Code Examples
fromdatetimeimportdatetimeprint("foo")bla=datetime.today()# use datetime.now() instead