python

[Python] F-string format datetime

import datetime

now = datetime.datetime.now()

print(f'{now:%Y-%m-%d %H:%M}')

# The example displays a formatted current datetime. The datetime format specifiers follow the : character.

# This is the output.
2019-05-11 22:39
Was this helpful?