题解 | #替换空格#

替换空格

http://www.nowcoder.com/practice/0e26e5551f2b489b9f58bc83aa4b6c68

str.replace(old, new[, max])
Python replace() 方法把字符串中的 old(旧字符串) 替换成 new(新字符串),如果指定第三个参数max,则替换不超过 max 次。

class Solution:
    def replaceSpace(self , s ):
        # write code here
        string = s.replace(' ', '%20')
        return string
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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