How can I change my code to new output?
My code:
import datetime
x = datetime.datetime.today()
print(x)
# Old Output: 2021-12-15 12:03:16.151803
but I want to create new output (remove the 803 from 12:03:16.151803 and save whole new output 2021-12-15 12:03:16.151)
# New Output: 2021-12-15 12:03:16.151
>Solution :
The simplest way to do that is by slicing it
Example:
x = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
print(x)