Python 字符串拼接

梨帅哥 · 2021年10月30日 · 1115 次阅读
import itertools

b = [7864, 284, 347, 7732, 8498]
x = list(itertools.permutations(b))
new_data = set()
for i in x:
    n_str = "".join([str(n) for n in i])
    new_data.add(n_str)
s = list(new_data)
min_n = sorted(s)[-1]  # -1为从大到小,0为从小到大
print(type(min_n))
print(n_str)  # 倒序输出
print(min_n)  # 从大到小输出

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册