baoyubo 8 kuukautta sitten
vanhempi
commit
d58aee189f
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 4 2
      DataGovernance.py

+ 4 - 2
DataGovernance.py

@@ -23,8 +23,10 @@ def jwd_to_area(location):
     }
     }
     response = requests.post(url=url, headers=headers, json=location, verify=False)
     response = requests.post(url=url, headers=headers, json=location, verify=False)
     if response.status_code == 200:
     if response.status_code == 200:
-        return response.json()['data'][0]['district']
-
+        try:
+            return response.json()['data'][0]['district']
+        except:
+            return None
 def put_area(table : str,longitude='longitude',latitude='latitude'):
 def put_area(table : str,longitude='longitude',latitude='latitude'):
     conn=None
     conn=None
     cur = None
     cur = None