我想用较少的代码执行以下操作:
if "address" in structured_data:
if "addressCountry" in structured_data["address"]:
data["country"] = structured_data["address"]["addressCountry"]这个是可能的吗?
发布于 2020-01-17 00:17:08
使用try怎么样?
try:
data["country"] = structured_data['address']['addressCountry']
except KeyError:
pass # handle what you want to dohttps://stackoverflow.com/questions/59779588
复制相似问题