locky преди 2 години
родител
ревизия
8c6d48354d
променени са 1 файла, в които са добавени 4 реда и са изтрити 5 реда
  1. 4 5
      Object/IPWeatherObject.py

+ 4 - 5
Object/IPWeatherObject.py

@@ -33,15 +33,14 @@ class IPQuery:
             res_data = eval(res.content.decode('utf-8'))
             if res_data['ret'] == 200:
                 district = res_data['data']['district']
-
-                # 城市数据不为空字符,拼上'市'字
                 city = res_data['data']['city']
-                if city != '':
-                    city += '市'
-
                 region = res_data['data']['region']
                 country_id = res_data['data']['country_id']
 
+                # 国内城市数据不为空字符,拼上'市'字
+                if country_id == 'CN' and city != '':
+                    city += '市'
+
                 # ip地址信息存表
                 IPAddr.objects.create(ip=ip, district=district, city=city, region=region, country_code=country_id)