import itertools lst = [112, 123, 98, 132, 120] list(itertools.permutations(lst,2)) # 输出: # [(112, 123), # (112, 98), # (112, 132), # (112, 120), # (123, 112), # (123, 98), # (123, 132), # (123, 120), # (98, 112), # (98, 123), # (98, 132), # (98, 120), # (132, 112), # (132, 123), # (132, 98), # (132, 120), # (120, 112), # (120, 123), # (120, 98), # (120, 132)] list(itertools.combinations(lst, 2)) # 输出: # [(112, 123), # (112, 98), # (112, 132), # (112, 120), # (123, 98), # (123, 132), # (123, 120), # (98, 132), # (98, 120), # (132, 120)]