import itertools
s = "8+33+47+49>2+7+9"
a = s.split(">")[0].split("+")
b = s.split(">")[1].split("+")
print(b)
combinations = itertools.combinations(b,2) # 生成两个元素组合
permutations = itertools.permutations(b,2) # 生成两个元素排列
print("组合")
for c in combinations:
print(c)
print("排列")
for p in permutations:
print(p)
out:
['2', '7', '9']
组合
('2', '7')
('2', '9')
('7', '9')
排列
('2', '7')
('2', '9')
('7', '2')
('7', '9')
('9', '2')
('9', '7')