0

这是我的代码(虽然不完整):

for k in range(len(ace)):
    recognitionstim.image = ace[k]
    old.draw()
    new.draw()

    if ace[k] in ac:
        recog = 'old'
    else:
        recog = 'new'

    win.flip()
    trialClock.reset()
    resp = event.waitKeys(keyList = ['a','l'])
    rt2 = trialClock.getTime()


    if resp == 'a' and recog == 'old':
        accuracy = 'correct'
    else:
        accuracy = 'incorrect'


    writer.writerow([k,ace[k],rt2,recog,resp,accuracy])

这段代码的作用是显示一系列图像,如果它们来自标题为“ac”的列表,它们将被称为“旧”。我要做的是编写代码,将“旧”的东西与按键(“a”)配对,这样如果旧的和“a”被按下,它会将其记录为“正确”。但是,它似乎无法读取“recog”。关于如何解决这个问题的任何想法?任何帮助将不胜感激。:)

4

1 回答 1

1

event.waitKeys returns a list so resp is a list. Instead of comparing to 'a' you should compare to ['a']:

if resp == ['a'] and recog == 'old':
    accuracy = 'correct'
于 2015-03-03T20:55:54.903 回答