python 没用内置replace函数,遍历,替换
替换空格
http://www.nowcoder.com/questionTerminal/4060ac7e3e404ad1a894ef3e17650423
# -*- coding:utf-8 -*-
class Solution:
# s 源字符串
def replaceSpace(self, s):
# write code here
str=''
for i in s:
if i==' ':
i = '%20'
str=str+i
return str
查看11道真题和解析