Python 为什么在vim中粘贴时会出现语法错误?

Python 为什么在vim中粘贴时会出现语法错误?,python,Python,SyntaxError:file/tools.py第65行的非ASCII字符“\xc2”,但未声明编码;有关详细信息,请参见我稍微修改了该代码: def latlong_distance(origin, destination):  lat1, lon1 = origin    lat2, lon2 = destination    radius = 6371    dlat = math.radians(lat2-lat1)    dlon = math.radians(lon2

SyntaxError:file/tools.py第65行的非ASCII字符“\xc2”,但未声明编码;有关详细信息,请参见

我稍微修改了该代码:

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
应该像这样分成两行:

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)

我试过了,没有例外。你能把那个文件附加到这里吗?

我对代码做了一些修改:

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
应该像这样分成两行:

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)

我试过了,没有例外。您能将该文件附加到此处吗?

这可能是一个空格问题(\xc2是空格字符),请尝试仅使用空格重新插入,不要使用其他字符。您还可以将
#-*-coding:utf-8-*-
放在文件的顶部,看看这是否有帮助

这可能是一个空格问题(\xc2是一个空格字符),请尝试仅使用空格,而不使用其他字符。您还可以将
#-*-coding:utf-8-*-
放在文件的顶部,看看这是否有帮助

您是否阅读了错误消息?这与vim有什么关系?可能是空格问题(\xc2是空格字符),请尝试仅使用空格重新登入,而不使用其他空格。您也可以将
#-*-编码:utf-8-*-
放在文件的顶部,看看是否有帮助。是的,rafe,谢谢。我会将其作为答案发布,这样我们就可以解决这个问题:)您读到错误消息了吗?这与vim有什么关系?可能是一个空格问题(\xc2是空格字符),请尝试仅使用空格重新删除,没有别的了。你也可以把
#-*-编码:utf-8-*-
放在文件的顶部,看看这是否有帮助。是的,是的,rafe,谢谢。我会把它作为答案发布,这样我们就可以解决这个问题:)