It does exactly what it says - converts a string to integer in a given numeric base. As per the documentation, int()
can convert strings in any base from 2 up to 36. On the low end, base 2 is the lowest useful system; base 1 would only have "0" as a symbol, which is pretty useless for counting. On the high end, 36 is chosen arbitrarily because we use symbols from "0123456789abcdefghijklmnopqrstuvwxyz" (10 digits + 26 characters) - you could continue with more symbols, but it is not really clear what to use after z.
"Normal" math is base-10 (uses symbols "0123456789"):
int("123", 10) # == 1*(10**2) + 2*(10**1) + 3*(10**0) == 123
Binary is base-2 (uses symbols "01"):
int("101", 2) # == 1*(2**2) + 0*(2**1) + 1*(2**0) == 5
"3" makes no sense in base 2; it only uses symbols "0" and "1", "3" is an invalid symbol (it's kind of like trying to book an appointment for the 34th of January).
int("333", 4) # == 3*(4**2) + 3*(4**1) + 3*(4**0)
# == 3*16 + 3*4 + 3*1
# == 48 + 12 + 3
# == 63
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…