我希望将一个字符串附加到从旧列表过滤出来的新列表中。
到目前为止,我尝试过以下方法:
到目前为止,我尝试过以下方法:
languages = ['thai01', 'thai02', 'thai03', 'jap01', 'jap02', 'jap03']
thai = []
japanese = []
def filter_str(lang):
if 'tha' in lang:
return True
else:
return False
filter_lang = filter(filter_str, languages)
thai = thai.append(filter_lang)
print(thai)
我的期望输出是:
['thai01', 'thai02', 'thai03']