数组中数字出现的次数

一个整型数组里除了两个数字之外,其他的数字都出现了两次。请写程序找出这两个只出现一次的数字。

 1 # -*- coding:utf-8 -*-
 2 class Solution:
 3     # 返回[a,b] 其中ab是出现一次的两个数字
 4     def FindNumsAppearOnce(self, array):
 5         diff = 0
 6         for num in array:
 7             diff ^= num
 8         diff &= -diff
 9         num1 = [0]
10         num2 = [0]
11         for num in array:
12             if num & diff == 0:
13                 num1[0] ^= num
14             else:
15                 num2[0] ^= num
16         return [num1[0],num2[0]]
17         # write code here