D
D
dro1d2018-02-05 12:40:12
Python
dro1d, 2018-02-05 12:40:12

How to limit time precision to milliseconds in python?

There is a variable in python
result = datetime.datetime.now()
How to limit the accuracy to milliseconds (accuracy to microseconds by default)
Tried to do something like

result.microsecond = int(result.microsecond / 1000) * 1000

But the python swears:
AttributeError: attribute 'microsecond' of 'datetime.datetime' objects is not writable

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question