直接替换
def replaceSpace(self, s): # write code here return s.replace(" ","%20")
正则表达式
import re class Solution: def replaceSpace(self, s): # write code here s=re.sub(r" ","%20",s) return s
def replaceSpace(self, s): # write code here return s.replace(" ","%20")
import re class Solution: def replaceSpace(self, s): # write code here s=re.sub(r" ","%20",s) return s