Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change milliseconds to seconds in python?

Tags:

python

date

I would like to change 1762 milliseconds to seconds 1.762. I have tried the below method, it gives me seconds in single-digit when i need seconds as mentioned above (i.e "1.762").

seconds=(rcccc/1000)%60
sec = int(seconds)
like image 837
fear_matrix Avatar asked May 15 '26 01:05

fear_matrix


1 Answers

Out of the many ways to address this, one way would be to specify that one of the operands is a float.

>>> 1762 / 1000 # Both integers
1

>>> 1762 / 1000.0 # One float
1.762
like image 114
Ami Tavory Avatar answered May 17 '26 14:05

Ami Tavory