Last active
September 22, 2021 23:14
-
-
Save U29/28963074240711175ffa5b955437ac35 to your computer and use it in GitHub Desktop.
おうちでワンナイト人狼集計プログラム
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import subprocess | |
import os | |
from tqdm import tqdm | |
path = "C:\\Users\\fukuden\\Desktop\\ワンナイト人狼集計\\作業台210923" | |
files = os.listdir(path) | |
files_dir = [f for f in files if os.path.isdir(os.path.join(path, f))] | |
print(files_dir) # ['dir1', 'dir2'] | |
print("jq .[].winner " + path + files_dir[0] + "\\finished_rooms.txt") | |
subprocess.call("chcp 65001", shell=True) | |
allWinners = [] | |
for i in tqdm(range(len(files_dir))): | |
if os.path.isfile(path + "\\" + files_dir[i] + "\\finished_rooms.txt"): | |
tempBin = subprocess.check_output("jq .[].winner " + path + "\\" + files_dir[i] + "\\finished_rooms.txt", shell=True) | |
else: | |
continue | |
tempStr = tempBin.decode("utf-8") | |
# delCodesBin = tempBin.replace('\\n','') | |
delCodesStr = tempStr.replace('\r\n','') | |
delNullStr = delCodesStr.replace('null', '') | |
allWinners += list(delNullStr) | |
# print(allWinners) | |
villager = allWinners.count('0') | |
werewolf = allWinners.count('1') | |
hangman = allWinners.count('2') | |
deathman = allWinners.count('3') | |
serialkiller = allWinners.count('4') | |
allgameNum = villager + werewolf + hangman + deathman +serialkiller | |
print('村人陣営: ' + str(villager)) | |
print('人狼陣営: ' + str(werewolf)) | |
print('吊人: ' + str(hangman)) | |
print('殉職者: ' + str(deathman)) | |
print('シリアルキラー: ' + str(serialkiller)) | |
print('全ゲーム: ' + str(allgameNum)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment