diff --git a/计算设备/缓存/84.py b/计算设备/缓存/84.py index 962595c..6cd67ad 100644 --- a/计算设备/缓存/84.py +++ b/计算设备/缓存/84.py @@ -21,4 +21,15 @@ def calculate_word_frequency(file_path): # 测试函数 top_10_words = calculate_word_frequency(testfilepath) for word, freq in top_10_words: - print(f"{word}: {freq}") \ No newline at end of file + print(f"{word}: {freq}") + +''' +python 提供了一种缓存调用函数的机制 +import functools + +# 使用 functools.lru_cache 缓存结果 +@functools.lru_cache(maxsize=None) +def calculate_word_frequency(file_path): + ... + retrun result +''' \ No newline at end of file