2024-05-19 07:57:46 发布
网友
我想用更少的代码执行以下操作:
if "address" in structured_data: if "addressCountry" in structured_data["address"]: data["country"] = structured_data["address"]["addressCountry"]
这可能吗
使用try怎么样
try
try: data["country"] = structured_data['address']['addressCountry'] except KeyError: pass # handle what you want to do
使用
try
怎么样相关问题 更多 >
编程相关推荐