Python 继续获得';SyntaxError:解析时出现意外EOF';运行我的应用程序时,可以';我不明白为什么

Python 继续获得';SyntaxError:解析时出现意外EOF';运行我的应用程序时,可以';我不明白为什么,python,syntax-error,Python,Syntax Error,我使用的是python3idle,它没有突出显示任何东西来告诉我语法错误是什么。提到它在第九行,虽然我看不到 这是代码,这是一个“速度检查器”的学校项目 import time#python module with time related functions file = open('speeders.txt', 'r') speeders = file.read() print (speeders) #prints out list of speeding cars reg_plate

我使用的是python3idle,它没有突出显示任何东西来告诉我语法错误是什么。提到它在第九行,虽然我看不到

这是代码,这是一个“速度检查器”的学校项目

import time#python module with time related functions

file = open('speeders.txt', 'r')
speeders = file.read()
print (speeders) #prints out list of speeding cars

reg_plate = int(input("Please enter the car's registration plate"))#registration plate
speed_limit = int(input("Please enter your speed limit in mph"))#assigns speed limit
input("Press enter when the car passes the first sensor")#assign values to the end and start time variables
start_time = time.time()
input("Press enter when the car passes the second sensor")
end_time = time.time()
distance = float(input("Enter the distance between the two sensors in metres")) #assigns a value to distance
time_taken = end_time - start_time #works out the time it took the car to travel the length of the road 

AverageSpeed = distance / time_taken #works out the average speed of the car
print ("The average speed of the car is", AverageSpeed, "m/s") #prints out the average speed of the car in m/s
AverageSpeedMPH = (AverageSpeed *  2.23694) #converts to mph
print ("That's", AverageSpeedMPH, "in mph") #prints out the speed in mph

if AverageSpeedMPH > speed_limit: #prints out whether car is speeding, adds to txt file
    print (reg_plate, "is speeding")
    file = open("speeders.txt", "a")
    file.write(reg_plate + ",")
    file.close()
else:
    print (reg_plate, "is not speeding, be on your merry way") #prints out if not speeding
下面是应用程序运行时显示的内容

Please enter the car's registration plate5
Please enter your speed limit in mph5
Press enter when the car passes the first sensor

Traceback (most recent call last):
  File "C:\Users\Szymon\Google Drive\Computing\Actual CA work\app2.py", line 9, in <module>
    input("Press enter when the car passes the first sensor")#lines 3-7 assign values to the end and start time variables
  File "<string>", line 0

    ^
SyntaxError: unexpected EOF while parsing
请输入汽车的车牌5
请以mph5输入您的速度限制
当车辆通过第一个传感器时,按enter键
回溯(最近一次呼叫最后一次):
文件“C:\Users\Szymon\Google Drive\Computing\Actual CA work\app2.py”,第9行,在
输入(“当车辆通过第一个传感器时按enter键”)#第3-7行为结束和开始时间变量赋值
文件“”,第0行
^
SyntaxError:分析时出现意外的EOF

看起来您正在使用Python2,但仍然在使用
input()
。尝试切换到Python3,或者使用
raw\u input()

使用
raw\u input()
而不是“input()”

如果使用输入,则键入的数据将被解释为Python 表示以gawd结束的表达式知道 对象,以及范围广泛的 可以生成的异常。所以你不应该使用输入,除非 你在做临时测试,只供用户使用 对Python表达式略知一二的人


在这里寻找更多

检查您使用的Python版本,并确保它是您应该使用的版本。您是否输入文本,然后按enter键?或者是从其他地方粘贴的“mph5”副本?