剑指offer习题二

# -*- coding:utf-8 -*-
class Solution:
    # array 二维列表
    def replaceSpace(self, s):
        # write code here
        new = ""
        flag = 0
        for i in s:
            if (i == " "):
                new = s.replace(i,"%20")
                flag = 1
        if(flag == 0):
            new = s
        return new

sol = Solution()

print(sol.replaceSpace("hello world"))

猜你喜欢

转载自blog.csdn.net/u012693077/article/details/80782287