Latest web development tutorials

Pythonは演習52、

Pythonの100リー Pythonの100リー

トピック:ビット単位以上を使用することを学びます|。

プログラム解析:0 | 0 = 0; 0 | 1 = 1; 1 | 0 = 1; 1 | 1 = 1

ソースコード:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

if __name__ == '__main__':
    a = 077
    b = a | 3
    print 'a | b is %d' % b
    b |= 7
    print 'a | b is %d' % b

上の例の出力は、次のとおりです。

a | b is 63
a | b is 63

Pythonの100リー Pythonの100リー