擅长:python、mysql、java
<p>对于单个<code>dict</code>,您可以使用<code>d.get('key', default)</code>,但是对于嵌套提取字符串没有简单的快捷方式。你可以用<code>try/except</code>来做</p>
<pre><code>try:
test_print = test['objects'][0]['productInfo'][0]['merchPrice']['promoExclusions'][0]
except KeyError:
test_print = default_value
print(test_print)
</code></pre>