题目链接:
https://leetcode-cn.com/problems/ti-huan-kong-ge-lcof/
题意:
将字符串中的空格替换成%20
题解:
遍历字符串,遇到空格则替换
代码:
class Solution:
def replaceSpace(self, s: str) -> str:
t=''
for x in s:
if x==' ':
t+='%20'
else :
t+=x
return t