###psychopyでpythonコードを回す際、IOErrorと定義のエラーがでます。
何故このエラーが出るのかわかりません。宜しくお願いします。
###発生している問題・エラーメッセージ
############## Running: C:\Users\hogehoge\Desktop\test.py ############## Traceback (most recent call last): File "C:\Users\hogehoge\Desktop\test.py", line 43, in <module> with open(datafile,"w") as f: IOError: [Errno 2] No such file or directory: u'C:\\Users\\hogehoge\\Desktop\\data/sub_2017_7_22_1942.csv' ######### Running: C:\Users\Miyuki KATO\Desktop\stim\katocode_0722.py ########## list indices must be integers, not str ()
###実際のコード
#-*- coding: utf-8 -*- from psychopy import visual, core, event, gui, data, misc from psychopy import parallel from psychopy.constants import * import gc, numpy, os, random, time, csv, cv2, codecs, sys, random try: results = [] datafile = [] # 参加者IDの取得 try: expInfo=misc.fromFile('lastParams.pickle') except: expInfo={'Participant':''} expInfo['dateStr']=data.getDateStr() dlg=gui.DlgFromDict(expInfo,title='Experiment',fixed=['dateStr']) if dlg.OK: misc.toFile('lastParams.pickle',expInfo) else: core.quit() # 画面の準備 myWin=visual.Window(fullscr=False,size=[800,800],monitor='Default',allowGUI=True,units='norm',color=(0,0,0)) trials = visual.TextStim(myWin, text = '',pos = (0,0), color = (-1,-1,-1)) stopwatch = core.Clock() #数字を出す diggits = ["1","2","3","4","5","6","7","8","9"] random.shuffle(diggits) trials.setText(diggits[1]) trialStart = core.Clock() for i in diggits: targetNo = i log = targetNo while trialStart.getTime() <0.5: trials.draw() myWin.flip() results.append([diggits[1]]) curD = os.getcwd() datafile = os.path.join(curD,'data/sub'+expInfo['Participant']+'_'+expInfo['dateStr']+'.csv') with open(datafile,"w") as f: f.write('trialList,log,answer,RT,\n') for r in results: f.write('{0}, {1}, {2}, {3}\n'.format(*r)) datafile.close() except TypeError, e: print e
###試したこと
タプルをリストに変換
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/07/23 03:48
2017/07/26 16:49 編集