我有两个问题:
1.我有一个字符串,我想要一个函数,在a$中搜索第一次出现的b$,并在第一次出现的b$之前返回a$的字符,如下所示:
Input: MISSISSIPPI,P ==> OUTPUT==>MISSISSI
我做了一个程序,但只删除了这样一个字符串
word=input("Add word: ")
m=input("Add char: ")
import re
removed=word.replace(m,"")
print(removed)
Input:MISSISSIPPi ==> Output:MISSISSII
我还想删除最后一个"i"
2.另一个问题是字符串,我想在每次找到字符b$时将给定的字符串(a$)拆分为子字符串。你知道吗
您可以使用split轻松完成以下操作,例如:
这是基本的;剩下的你应该能自己搞清楚
1。你知道吗
2。你知道吗
你为什么要进口稀土?你可以用回复sub:
相关问题 更多 >
编程相关推荐