相关文章推荐
霸气的花卷  ·  python list 错位相减 ...·  2 月前    · 
憨厚的大脸猫  ·  python ...·  2 月前    · 
小猫猫  ·  python tornado ...·  2 月前    · 
有腹肌的充值卡  ·  pycharm console 清屏 ...·  1 月前    · 
逃跑的键盘  ·  Python while循环-阿里云·  11 月前    · 
快乐的卤蛋  ·  React 16.x折腾记 - (3) ...·  1 年前    · 
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.