题解 | #修正错误的字母#

修正错误的字母

https://www.nowcoder.com/practice/efc02a6e769a4dc3b1433a36109c9217

a=input()
b=a.replace('a*','ab')
print(b)
# Python replace() 方法把字符串中的 old(旧字符串) 替换成 new(新字符串),如果指定第三个参数max,则替换不超过 max 次。

str = "this is string example....wow!!! this is really string";
print str.replace("is", "was");
print str.replace("is", "was", 3);
#输出:thwas was string example....wow!!! thwas was really string
      thwas was string example....wow!!! thwas is really string

全部评论

相关推荐

点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 11:33
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务