leetcode——191.位1的个数

class Solution(object):
    def hammingWeight(self, n):
        """
        :type n: int
        :rtype: int
        """
        return bin(n).count('1')
执行用时 :16 ms, 在所有 Python 提交中击败了94.92%的用户
内存消耗 :11.7 MB, 在所有 Python 提交中击败了31.64%的用户
 
                                                                                                  ——2019.10.10
我的前方是万里征途,星辰大海!!
原文地址:https://www.cnblogs.com/taoyuxin/p/11649290.html