python - 当我将它粘贴到 vim 中时,为什么会出现语法错误?

标签 python

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/

相关文章:

python - xpath 正则表达式不会在 lxml.etree 中搜索 tail

python - ***在Python -3中是什么意思?

python - 冗余 If 语句和正则表达式

python - Pandas 的 CSV 加载错误

python - 如何使用 for 循环创建字典列表?

python - 由于图像杂质,skimage 峰值局部最大值发现多个非常接近的点

python - 安装/加载 github::KMeansRex Python 库

python - 将 Anaconda root 环境迁移到新机器

Python查找重复项: Find out if there are duplicate numbers and the index diff is at most k

python - Airflow :使用 BashOperator 运行时,Python 脚本如何发出失败的任务信号