Python 搜索带有换行符的文本的子字符串
我有一本字典Python 搜索带有换行符的文本的子字符串,python,python-3.x,list,dictionary,line-breaks,Python,Python 3.x,List,Dictionary,Line Breaks,我有一本字典 reason = { "Tool error": ["The problem with the term"], "Verification error": ["modify the script","Appeal registered"] } 我有一个列表,在其中我从字典中搜索一个值,如果搜索成功,则替换该键 该列表包含换行符 因为列表包含换行符,所以我的脚本只查找
reason = {
"Tool error": ["The problem with the term"],
"Verification error": ["modify the script","Appeal registered"]
}
我有一个列表,在其中我从字典中搜索一个值,如果搜索成功,则替换该键
该列表包含换行符
因为列表包含换行符,所以我的脚本只查找列表中的第一行
我的剧本:
for n, m in zip(task_list,tabl_inf):
print(n[2])
for key, item in reason.items():
for itm in item:
if itm in n[2]:
reason_val = key
else: reason_val = "not found"
result.append([n[0],n[1],m,n[2],n[13],n[3].strftime('%x %X'),n[4].strftime('%x %X'),reason_val])
如何搜索字典值在整个列表中?请同时共享
列表。