def latlong_distance(origin, destination):
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371
dlat = math.radians(lat2-lat1)
dlon = math.radians(lon2-lon1) a = math.sin(dlat/2) * math.sin(dlat/2) + math.cos(math.radians(lat1)) * math.cos(math.radians(lat2)) * math.sin(dlon/2) * math.sin(dlon/2)
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1-a))
d = radius * c
return d * 1000
语法错误:文件/tools.py 中第 65 行的非 ASCII 字符 '\xc2',但未声明编码;见http://www.python.org/peps/pep-0263.html详情
最佳答案
这可能是一个间距问题(\xc2 是一个空格字符),尝试仅使用空格重新缩进,别无其他。您还可以将 # -*- coding:utf-8 -*-
放在文件的顶部,看看是否有帮助。
关于python - 当我将它粘贴到 vim 中时,为什么会出现语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5228707/