2011-08-16 18 views

回答

2
Help on class int in module __builtin__: 

class int(object) 
| int(x[, base]) -> integer 
| 
| Convert a string or number to an integer, if possible. A floating point 
| argument will be truncated towards zero (this does not include a string 
| representation of a floating point number!) When converting a string, use 
| the optional base. It is an error to supply a base when converting a 
| non-string. If base is zero, the proper base is guessed based on the 
| string content. If the argument is outside the integer range a 
| long object will be returned instead. 

所以這是您正在解析,以數字範圍內的base32串從0 .. 9a .. v

1

第二個參數是在其中轉換是要進行的鹼:

help(int) 

class int(object) 
| int(x[, base]) -> integer 
.... 
0

下一次你遇到類似的問題 試試這個:二進制數的

>>> help (int) 

打印十進制值作爲字符串提供

>>> int('1010101011',2) 
683 

打印作爲字符串提供的十進制數的十進制值

>>> int('1010101011',10) 
1010101011 
>>> 

失敗了,因爲我們沒有在二進制

>>> int('120000000',2) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ValueError: invalid literal for int() with base 2: '120000000' 
有符號 「2」
相關問題