給定一個串列["one day", "second day"],如何判斷每個List是否存在于指定的字串中?
string_to_be_searched = "總有一天我會找到你的"
它確實回傳找到的實際句子
uj5u.com熱心網友回復:
可能的解決方案如下:
lst = ["one day", "second day"]
string = """one day i will find you"""
for item in lst:
if item in string:
print(f"'{item}' IS PRESENT in the string '{string}'")
else:
print(f"'{item}' iS MISSING from the string '{string}'")
印刷
'one day' IS PRESENT in the string 'one day i will find you'
'second day' iS MISSING from the string 'one day i will find you'
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/452144.html
標籤:python-3.x 列表
