Template
finish 01-homework
This commit is contained in:
@@ -0,0 +1 @@
|
||||
One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone.
|
||||
@@ -0,0 +1,22 @@
|
||||
'''
|
||||
Author: SJ2050
|
||||
Date: 2021-10-10 23:22:04
|
||||
LastEditTime: 2021-10-10 23:34:06
|
||||
Version: v0.0.1
|
||||
Description: Solution for homework 1.
|
||||
Copyright © 2021 SJ2050
|
||||
'''
|
||||
|
||||
if __name__ == '__main__':
|
||||
with open('essay.txt', 'r') as fp_in:
|
||||
content = fp_in.read()
|
||||
word_map = {}
|
||||
words = content.split()
|
||||
for w in words:
|
||||
if w in word_map:
|
||||
word_map[w] += 1
|
||||
else:
|
||||
word_map[w] = 1
|
||||
|
||||
for (k, v) in word_map.items():
|
||||
print(f'{k}: {v}')
|
||||
Reference in New Issue
Block a user