I need to turn a formatted integer into a regular integer:
- 000000000001 needs to be turned into 1
- 000000000053 needs to be turned into 53
- 000000965948 needs to be turned into 965948
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?
The leading zeroes are considered octal. I am assuming that you are converting the string “000000013”, not literal 000000013, so you should be able to convert these to base 10 integer by
int("000000013",10)If the “harm has already been done”, and they are literals, that have already been converted to octal literals, you can use the following (beware, this is harmful and heresy:)