LeetCode-67-Add Binary Python的二十进制互转

来源:互联网 发布:软件质量保证承诺书 编辑:程序博客网 时间:2024/06/06 01:10

注意2进制表示方法是字符串,转出来的二进制带个0b,必要时要去掉

class Solution(object):    def addBinary(self, a, b):        """        :type a: str        :type b: str        :rtype: str        """        return bin(int(a,2)+int(b,2))[2:]


原创粉丝点击