Not getting exact result in python with the values leading zero. Please tell me what is going on there

前端 未结 6 685
温柔的废话
温柔的废话 2020-12-07 02:28

zipcode = 02132

print zipcode

result = 1114

6条回答
  •  青春惊慌失措
    2020-12-07 02:55

    Quite apart from the octal caper:

    Zip codes, social security "numbers", credit card "numbers", phone "numbers", etc are NOT numbers in the sense that you can do meaningful arithmetic on them, so don't keep them as integers, keep them as strings.

提交回复
热议问题