请实现一个函数,把字符串 s
中的每个空格替换成"%20"。
输入:s = "We are happy." 输出:"We%20are%20happy
class solution(object): def replacespace(self,s): """ :type s: str :rtype: str """ s = list(s) for i in range(s): if s[i] == ‘ ‘: s[i] = ‘%20‘ return ‘‘.join(s)
原文:https://www.cnblogs.com/minidu/p/13575526.html