【简单】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

posted on 2022-05-18 21:17  墙角一枝花  阅读(43)  评论(0编辑  收藏  举报