牛客网上的剑指 offer的在线编程:
题目描述:
# -*- coding:utf-8 -*-
class Solution:
def NumberOf1(self, n):
if n >= 0:
bina = bin(n)
count = bina.count('1')
return count
else:
bina = bin(abs(n) - 1)
count = 32 - bina.count('1')
return count