小编Ran*_*dom的帖子

一般来说序列是否有str.replace等价物?

是否有类似于str.replace的方法可以执行以下操作:

>> replace(sequence=[0,1,3], old=[0,1], new=[1,2]) 
[1,2,3]
Run Code Online (Sandbox Code Playgroud)

它应该像str.replace一样:用另一个序列替换序列的"片段",而不是用"new"的元素映射"old"的元素.谢谢 :)

python string sequence str-replace python-3.x

4
推荐指数
1
解决办法
106
查看次数

标签 统计

python ×1

python-3.x ×1

sequence ×1

str-replace ×1

string ×1