class Solution: def replaceSpace(self , s: str) -> str: # write code here mystr=[] for c in s: if c==' ': mystr.append('%20') else: mystr.append(c) #注意.join的用法 return ''.join(mystr)