注意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:]
注意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:]