首页 > 解决方案 > 为什么我得到无效字符

问题描述

我正在使用 GPS 传感器和 Raspberry Pi 3b+ 运行一个简单的代码,并希望对读数执行一些计算,我得到的唯一错误是“SyntaxError:标识符中的无效字符”,但该行看起来很简单。

def Tasks():
    def CalculateSpeed():
        if x[-1] and y[-1] == even:
            ChangeInLatitude=x1-x
            DistanceConversion=ChangeInLatitude*111111
            Speed=DistanceConversion/TimeElapsed
            Speed=str(speed) + meters/interval 
            print (“The object this module is attached to is moving at “ + Speed)

错误代码将错误标记放在第 8 行“the”的末尾

标签: python-3.x

解决方案


你有 unicode 引号。

foo = “bar“

无效也不是

foo = “bar”

但是单引号或双“基本”引号是:

foo = "bar"

推荐阅读