I need to turn a formatted integer into a regular integer:
And so on.
It seems that a simple int(000000000015)
results in the number 13. I understand there is some weird stuff behind the scenes. What is the best way to do this accurately every time?
Numbers starting with 0
are considered octal.
>>> 07
7
>>> 08
File "<stdin>", line 1
08
^
SyntaxError: invalid token
You can wrap your zero-padded number into a string, then it should work.
>>> int("08")
8
int()
takes an optional argument, which is the base, so the above would be the equivalent of:
>>> int("08", 10)
8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With