请实现一个函数,把字符串 s 中的每个空格替换成"%20"。
示例 1:
输入:s = "We are happy."
输出:"We%20are%20happy."
限制:
0 <= s 的长度 <= 10000
作者:Krahets
链接:https://leetcode-cn.com/leetbook/read/illustration-of-algorithm/50ywkd/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
class Solution:
def replaceSpace(self, s: str) -> str:
t=''
for x in s:
if x==' ':
t+='%20'
else:
t+=x
return t