我有以下字符串/文本streets_and_names = '''#street 49 description someone lives there name Paul#street 51 description no one lives there name no name#street 43 description someone lives there name Mark#street 42 description no one lives there name no name#'''我想通过从中删除以下行来获得输出 description no one lives there name no name其余的保持原样。有人知道吗?谢谢。
1 回答
LEATH
TA贡献1936条经验 获得超6个赞
如果您的示例是字面的并且只是执行了res = streets_and_names.replace(' description no one lives there\n name no name', ''),您将得到您想要的结果。
结果:
'''
#
street 49
description someone lives there
name Paul
#
street 51
#
street 43
description someone lives there
name Mark
#
street 42
#
'''
添加回答
举报
0/150
提交
取消