赞
踩
代码:
顺着题目意思写即可
- s=input()
- n=int(input())
- for i in range(n):
- l, r, x, y = input().split()
- if x not in s[int(l)-1:int(r)]: # 如果待替换字符不在区间内则跳过
- continue
- else:
- # 找到待替换字符的位置,用replace函数进行替换
- s=s[:int(l)-1]+s[int(l)-1:int(r)].replace(x,y)+ s[int(r):]
- print(s)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。