题目链接:7-29 删除字符串中的子串
str1 = input().split('\n')[0]
str2 = input().split('\n')[0]
while str2 in str1:
str1 = str1.replace(str2, "") // 删除子串
print(str1)
#include
#include
using namespace std;
int main(void) {
string s1, s2;
size_t len2, pos;
getline (cin, s1); //按行获取输入
getline (cin, s2);
len2 = s2.length();
pos = s1.find(s2);
while (pos != -1) {
s1 = s1.erase (pos, len2); // 删除子串
pos = s1.find(s2);
}
cout << s1 << endl;
return 0;
}