Python Exercise Example 52
Topic:Learn to use the bitwise OR |.
Program analysis:0|0=0; 0|1=1; 1|0=1; 1|1=1
Example (Python 2.0+)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__ == '__main__':
a = 0o77
b = a | 3
print ('a | b is %d' % b)
b |= 7
print ('a | b is %d' % b)
The output result of the above example is:
a | b is 63 a | b is 63Other Extensions
Python 100 Examples