【发布时间】:2011-08-27 08:39:05
【问题描述】:
假设我们有一个字符串a = "01000111000011" 和n=5 "1"s。 ith "1",我想用"ORANGE" 中的ith 字符替换。
我的结果应该是这样的:
b = "0O000RAN0000GE"
在 Python 中解决这个问题的最好方法是什么?是否可以将索引绑定到每个替换?
非常感谢! 海尔加
【问题讨论】:
标签: python string replace loops substitution