开发者

Reading Log Files and Getting Avg In python [duplicate]

开发者 https://www.devze.com 2022-12-07 17:46 出处:网络
This question already has answers here: How to read numbers in text file as numbers in to list? (5 answers)
This question already has answers here: How to read numbers in text file as numbers in to list? (5 answers) Finding the average of a list (25 answers) Closed 1 hour ago.

i am working on a project and am making a rock paper sc开发者_运维问答issors robot however i want the robot to learn with every single input it gets. My program logs all old inputs into a log.log file. It sorts old inputs into a number, either 1, 2 or 3. I am struggling to get my program to get an average of the file.

The log.log file looks something like this:

1
3
2
3
2
1
3

I need to somehow transfer that into an average which would be 2.14285714286.

Any help would be much appreciated.

I have tried reading the file into a list and then taking the average. Im not very good at understanding the log module wich is why i am having issues

0

精彩评论

暂无评论...
验证码 换一张
取 消