针对pulse-transit的工具

This commit is contained in:
2025-02-22 16:12:02 +08:00
commit 6bc25b4e3a
7719 changed files with 1530886 additions and 0 deletions

26
txt_counter.py Normal file
View File

@@ -0,0 +1,26 @@
from collections import Counter
def count_lines(file_path):
# 读取文件并统计每一行的出现次数
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
# 使用Counter统计每一行的出现次数
line_counts = Counter(lines)
# 按出现次数从高到低排序
sorted_line_counts = line_counts.most_common()
return sorted_line_counts
def main(file_path):
sorted_line_counts = count_lines(file_path)
# 打印结果
for line, count in sorted_line_counts:
print(f'{line.strip()} - Count: {count}')
if __name__ == "__main__":
# 指定你的txt文件路径
file_path = "D://python_study//big_boss//doc//output//all_processed.txt"
main(file_path)