【简单】9、二进制求和(知识点:bin和int内置函数、format)
def addBinary(a, b):
return bin(int(a,2)+int(b,2))[2:]
a = "1010"
b = "1011"
# # "10101"
print(addBinary(a, b))
一、format函数
https://www.runoob.com/python/att-string-format.html
def addBinary(a, b):
return bin(int(a,2)+int(b,2))[2:]
a = "1010"
b = "1011"
# # "10101"
print(addBinary(a, b))
一、format函数
https://www.runoob.com/python/att-string-format.html