验证坐标是否合法
def is_valid_coordinates(coordinates):
import re
pattern = re.compile('''\s*
-?\d{1,3}(.\d+)?
,\s*
-?\d{1,3}(.\d+)?
$''', re.X)
result = pattern.match(coordinates)
if result:
x, y = result.group().split(',')
if abs(float(x)) <= 90 and abs(float(y)) <= 180:
return True
else:
return False
else:
return False