字符串空格替換

題目:app

  請實現一個函數,將一個字符串中的空格替換成「%20」。例如,當字符串爲We Are Happy.則通過替換以後的字符串爲We%20Are%20Happy。函數

代碼:spa

1 # -*- coding:utf-8 -*-
2 class Solution:
3     # s 源字符串
4     def replaceSpace(self, s):
5         # write code here
6         return s.replace(' ','%20')
相關文章
相關標籤/搜索