how to do bitwise exclusive or of two strings in python?

后端 未结 12 1767
攒了一身酷
攒了一身酷 2020-12-01 02:34

I would like to perform a bitwise exclusive or of two strings in python, but xor of strings are not allowed in python. How can I do it ?

12条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 03:25

    Do you mean something like this:

    s1 = '00000001'
    s2 = '11111110'
    int(s1,2) ^ int(s2,2)
    

提交回复
热议问题