添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm a little bit confuse in using int(x, [base]). Can someone explain why it keeps throwing this error? Sorry, im just starting to learn the basics.

Traceback (most recent call last):
  File "<pyshell#63>", line 1, in <module>
     int('23123',1)
ValueError: int() base must be >= 2 and <= 36  
Traceback (most recent call last):
  File "<pyshell#75>", line 1, in <module>
int('123',3)
ValueError: invalid literal for int() with base 3: '123'
                If you want to decode a number in base 3, then the string has to be a base 3 number. Why do you think that '123' is a base 3 number?
– quamrana
                Jan 31, 2018 at 9:56
                A number in base three can only contain 0, 1 and 2. Base three has only three possible digits. That's why it is base 3.
– khelwood
                Jan 31, 2018 at 9:57
                "Base 1" would be just counting fingers, ||||| is 5, |||||||||||||||||||||||||||||| is 30. Not a very useful base to be working in.
– deceze
                Jan 31, 2018 at 9:59
                Thank you for your answers, now I remember how the base number works. Sorry for asking this noob question. Base 3 0 1 2 10 11 12 20 21 21 22 . . . . . . . .      ex: Base 7     0 1 2 4 5 6 10 11 12 13 14 15 16 20 . . . . . . .. . . .
– Llallum
                Jan 31, 2018 at 10:45
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.