l = [‘123a’,‘456b’,‘789c’]
ll = [s for s in l if ‘a’ in s]
这是通过判断语句
lst = [“123a”, “456b”, “789c”]
lst = list(filter(lambda x: x.find(“a”) >= 0, lst))
print(lst)
这是通过函数
l = [‘123a’,‘456b’,‘789c’]
ll = [s for s in l if ‘a’ in s]
这是通过判断语句
lst = [“123a”, “456b”, “789c”]
lst = list(filter(lambda x: x.find(“a”) >= 0, lst))
print(lst)
这是通过函数