Logical OR for Bit-string in Python
问题 What i want to do is have the result of logical OR for two bit-strings. For example: a='010010' b='000101' c=LOGIC_OR(a,b) c 010111 The error i encounter most of the time is when I convert 'b' from string to binary it removes leading zeros. Others methods i have used convert 'a' and 'b' to integers. Generally nothing is working and help would be much appreciated. Thanks in advance 回答1: Here are a couple of alternative methods. Third-party bitarray library: from bitarray import bitarray a=