我正在製作visuall反應時間測試儀和記錄儀。我無法弄清楚這有什麼問題,請幫忙。它引發了ReactionTime未定義的錯誤。再經過你一些其他虛假錯誤修復使用Python的反應時間測試測試儀
#Imports
import pygame
import pyHook
import pythoncom
import logging
import sys
import win32api
import win32con
from datetime import datetime
from datetime import timedelta
from random import randint
from math import *
#Creates PyGame Window
pygame.init()
screen = pygame.display.set_mode((640, 480))
screen.fill((255, 255, 255))
#Starts Counter to Start Reaction Time Start
a= 0
for x in range(0, 100):
a = a +1
print(datetime.now())
#Starts Reaction Time After Dot Appears
if a == 100:
pygame.draw.circle(screen, (0, 0, 0), (320, 240), 20)
ReactionStart= datetime.now()
print(ReactionStart)
#Tells If Someone Pushes A Key And Stops Timer
def OnKeyboardEvent(event):
ReactionEnd == datetime.now()
print (ReactionEnd)
#Makes Sure That The Program Knows a Key was pressed
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
#Calculates Reaction Time
ReactionTime == ReactionEnd - ReactionStart
print (ReactionTime)
#Unknown
pygame.display.flip()
#Makes Sure You Can exit The Test
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
不是調試服務... – dawg
您甚至沒有添加(完整)錯誤消息。 – furas
'=='與'=' – bsoist