2024-04-26 05:05:47 发布
网友
在Python中,我有这样一个列表:
list = ["item.1", "sdfhkjdsffs/THIS-STRING", "fsdhfjsdhfsdf/THIS-STRING", item4/THIS-STRING, item5]
如何为列表中不包含"THIS-STRING"的每个项目添加"some string"?你知道吗
"THIS-STRING"
"some string"
result = [x if x.find("SOME-STRING")>=0 else x+"some string" for x in list]
相关问题 更多 >
编程相关推荐