Starting with the original answer, which explains how a NOR gate can be implemented using AND and NOT:
You are asking for a NOR bitwise operation:
r = not (a or b)
Also, you can use De Morgan's law, that says that it's equivalent to:
r = (not a) and (not b)
The poster than translates that pseudo-code into the Python you posted. For some reason he used ^ 0b11111111 to do a binary NOT, rather than simply ~, which is what I would have chosen. If we switch (a ^ 0b11111111) to the simpler ~ then we get:
bin(~a & ~b)
That expression is how you write "(not a) and (not b)" in Python. ~ means NOT and & means AND.
A binary NOT flips all of the bits in a number. 0 becomes 1 and 1 becomes 0. The direct way to do that is with ~. An indirect way to flip all the bits in a number is to XOR it with all 1 bits. That has the same effect, it's just longer to write.
Or actually, to be more precise, it has almost the same effect. ^ 0b11111111 flips the first eight bits of the number because there are eight 1's. Whereas ~ flips all of the bits. If you're interested in only the first 8 bits then you can add & 0b11111111, which truncates the results to 8 bits:
>>> bin((~a & ~b) & 0b11111111)
'0b10011100'
In my opinion this is better than the mysterious ^ 0b11111111.
bin(~(a|b) & 0xff)- Maxime Chéramy