The python dictionary is written in the table.

import os
from collections import Counter
sumsdata = []
for fname in os.listdir(os.getcwd()):
    if os.path.isfile(fname) and fname.endswith(".txt"):
        with open(fname,"r",encoding="utf-8") as fp:
            data = fp.readlines()
            fp.close()
        sumsdata += [line.strip().lower() for line in data]
cnt = Counter()
for word in sumsdata:
    cnt[word] += 1
cnt = dict(cnt)
print(cnt)
for key,value in cnt.items():
    dic = key + ":" + str(value)
    -sharp print(data)


".txt" is something like this {Beijing, China, Beijing, Shanghai, Chongqing
}

how to write data into a table to facilitate query

Mar.15,2021

print to txt, open with excle, select the delimiter:, export.

Menu