擅长:python、mysql、java
<p>下面是一个使用<a href="https://docs.python.org/3/library/functools.html#functools.reduce" rel="nofollow noreferrer">reduce</a>的解决方案:</p>
<pre><code>from functools import reduce
seq = 'abc'
result = reduce(lambda value, key: { key : value }, reversed(seq), {})
print(result)
</code></pre>
<p><strong>输出</strong></p>
<pre><code>{'a': {'b': {'c': {}}}}
</code></pre>