int('11111111', 2)
255
def binary2int(s):
sum = 0
for i in range(len(s)):
sum += int(s[i]) * 2**(len(s)-i-1)
print sum
binary2int('11111111')
255
int('11111111', 2)
255
def binary2int(s):
sum = 0
for i in range(len(s)):
sum += int(s[i]) * 2**(len(s)-i-1)
print sum
binary2int('11111111')
255