比如输入1和2,组合为11,22,12,21共有4种可能
from itertools import * sCharacters = '12' for aCombination in product(sCharacters, repeat=2): print(''.join(aCombination))
python就是这么强大,几句代码便可完成复杂组合任务。
本文分享自 作者个人站点/博客 前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!