题目描述

请实现一个函数,将一个字符串中的每个空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
时间限制:1秒 空间限制:32768K 热度指数:1240896
本题知识点: 字符串
 
1.Python的replace方法

运行时间:36ms

占用内存:5712k

# -*- coding:utf-8 -*-
class Solution:
    # s 源字符串
    def replaceSpace(self, s):
        # write code here
        return s.replace(" ","%20")

 

相关文章:

  • 2022-01-19
  • 2022-12-23
  • 2021-06-07
  • 2021-06-01
  • 2022-01-12
  • 2021-10-13
  • 2021-12-29
  • 2021-07-28
猜你喜欢
  • 2021-11-29
  • 2021-10-22
  • 2021-06-16
  • 2021-10-07
  • 2021-08-08
  • 2021-11-14
相关资源
相似解决方案