#示例10-11 计算整数0~5的累计异或的3种方式 import functools import operator #方法1: n = 0 for i in range(1,6): n ^= i print(n) #方法2: x1 = functools.reduce(lambda a, b: a^b, range(6)) print(x1) #方法3: x2 = functools.reduce(operator.xor, range(6)) print(x2)
标签:functools,reduce,异或,累计,x2,range,整数,print From: https://www.cnblogs.com/bravesunforever/p/17369071.html