# -*- coding: UTF-8 -*-
'''
@IDE :PyCharm
@Author :WangZheng
@Date :2021/11/11 21:08
@pagePath:
'''
def test(params):
mlist = []
count = 0
for i in params:
for j in params:
for k in params:
# 判断 三个值都不能相同
if i!=j and j!=k and k!=i:
mlist.append(i+j+k)
count += 1
print("一共有 {} 中情况,分别是 {}".format(count,mlist))
test("1234")
运行结果:
一共有 24 中情况,分别是 ['123', '124', '132', '134', '142', '143', '213', '214', '231', '234', '241', '243', '312', '314', '321', '324', '341', '342', '412', '413', '421', '423', '431', '432']