擅长:python、mysql、java
<pre><code>In [43]: mydict1 ={
....: 'Better' : {'vara1':'vala1', 'varb1':'valb1'},
....: 'BetterThanBest' : {'vara2':'vala2', 'varb2':'valb2'} }
In [44]: mydict2 = {
....: '/check12/BetterThanBest':'/dir3/BetterThanBest' }
In [51]: keys1=sorted(list(mydict1),key=len,reverse=True) #sort the keys by length, descending order
In [52]: keys2=sorted(list(mydict2),key=len,reverse=True) #sort the keys by length, descending order
In [54]: [x for x in keys1 for y in keys2 if x in y][0]
Out[54]: 'BetterThanBest'
</code></pre>