收藏:①极市开发DeepLearning ②Git使用

剑指offer-02

描述: 
请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。

1 __author__ = "WSX"
2 def replaceSpace(s):
3     result = s.replace(" ", "%20")
4     return result
5 print(replaceSpace("hello world"))

 

posted @ 2019-04-21 22:01  WSX_1994  阅读(97)  评论(0编辑  收藏  举报