##Cargar fichero import os times = [] actions = [] with open(os.path.join(os.getcwd(),"3-comparacion_todas\mesa\pr32","3D3-1.txt")) as log: for line in log: if not (line == "\n"): time = line.partition("\t")[0] action = line.partition("\t")[2] action = action.partition("\t")[0] times.append(time) actions.append(action) ##Numero de acciones de cada tipo go = 0 stop = 0 left = 0 right = 0 ##Numero de impactos con las bombas bomb = 0 ##Numero de quiz resueltos ended = 0 ##Numero de errores wrong = 0 for action in actions: if (action == "PLAYER GO"): go = go+1 elif (action == "PLAYER STOP"): stop = stop+1 elif (action == "PLAYER LEFT"): left = left+1 elif (action == "PLAYER RIGHT"): right = right+1 elif (action == "BOMB CONTACT"): bomb = bomb+1 elif (action == "QUIZ ENDED"): ended = ended+1 elif (action == "WRONG ANSWER"): wrong = wrong+1 print "Go:" + go + " Stop:" + stop + " Left:"+ left + " Right:" + right print "Bombs:" + bomb print "Ended:" + ended print "Wrong:" + wrong ##Tiempo medio en completar una pregunta (QUESTION CELL -> QUIZ ENDED) positions = [] for i, j in enumerate(actions): if j == "QUESTION CELL": positions.append(i) if j == "QUIZ ENDED": positions.append(i)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question