在字典键中查找字符串,其中字符串不是dict中的键

Won*_*ifu 1 python dictionary key

我正在尝试在搜索字典列表时找到密钥.但是字符串与字典键不完全匹配.这是我到目前为止:

if string in d.keys():
    print 'found'
Run Code Online (Sandbox Code Playgroud)

我想找到的钥匙.

Hug*_*ell 5

我认为没有什么比通过d键进行线性扫描更好的了.

print [k for k in d if string in k]
Run Code Online (Sandbox Code Playgroud)