解释放在这个链接里了。

#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
# 
# @param array int整型一维数组 
# @return int整型一维数组
#
class Solution:
    def FindNumsAppearOnce(self , array) :
        # write code here
        tmp = 0
        for num in array:
            tmp ^= num
        # 找到最低位的1
        group = 1
        while group & tmp == 0:
            group = group << 1
        # 分组寻找两个只出现过一次的数
        tmp1 = 0 ; tmp2 = 0
        for num in array:
            if num & group == 0:
                tmp1^=num
            else:
                tmp2^=num
        return sorted([tmp1,tmp2])

array = [1,4,1,6]
print(Solution().FindNumsAppearOnce(array))