剑指offer05替换字符串空格

# coding:utf-8
"""
Name : 剑指offer05.py
Author  : qlb
Contect : 17801044486@163.com
Time    : 2021/2/7 9:56
Desc: 替换字符串空格
"""
# python 字符串不可原地修改 因此先将字符串转换为列表
class Solution:
    def replaceSpace(self, s: str) -> str:
        s = list(s)
        for i in range(len(s)):
            if s[i] == ' ':
                s[i] = "%20"
        return  ''.join(s)
原文地址:https://www.cnblogs.com/cnugis/p/14384137.html