Python 遍历一个数组并计算最终结果
巴扎黑
巴扎黑 2016-11-11 16:42:10
0
1
880

我有一段代码,如下: 
result = 0 
for item in [3, 2, 5]: 
result ^= item 
print(result) 
以上这个 for 循环能不能用一个函数,或一个语句就计算出来?

巴扎黑
巴扎黑

reply all(1)
面对疾风吧

reduce(operator.ixor,[3,2,5])

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!