
[英]Get all combinations of multiple characters substitution at specific positions within a string
[英]How to change letters of a word at specific positions and obtain all the possible combinations after substitution of new letters?
我想通过使用 python 更改特定位置的某些字母来改变一系列字母。 如果我的初始序列是 s='abcdefghij' 并且我想用列表 list=[klmnop] 中的字母替换位置 1,3,5,7 处的字母,以便我可以获得所有可能的组合
s = 'bcde'
最终 = []
如果 s[0] == 'b':
final = ['{}{}'.format(i, s[1:], s[:3]) for i in 'moon']
打印(最终)。
我试过这个,但它只能替换一个字母,我如何替换一个单词的多个字母。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.