【发布时间】:2021-10-02 06:11:42
【问题描述】:
我正在尝试在 python 字符串中进行一些替换,我有类似的数据
The lyrics is not that bad! 我想用 good 替换 not that bad。这是我拥有的几个数据示例:
I HAVE THIS -- WANT TO CONVERT LIKE THIS
The lyrics is not that bad! -- The lyrics is good!
Food is not bad. -- Food is good.
!! not !! bad !! -- !! good !!
notbad -- good
The song is not extremely gently bad for my ears. -- The song is good for my ears.
The sight is not very very bad. -- The sight is good.
我正在尝试编写一些适用于所有人的通用脚本。我是python的新手,我试过str.replace(),找到str.find()然后替换。但没有成功。
【问题讨论】:
-
str.replace?? -
到目前为止你有什么尝试?
-
所以我希望它适用于不同的句子。喜欢:- 输入是“歌词还不错!”输出是“歌词很好!”和输入 - 视力不是很差。输出 - 视线很好。我怎样才能把它变成一个程序?........我试过 str.replace,我也试过 str.find 然后替换,但没有任何效果。
标签: python python-3.x replace