diff --git a/11 概念认知/函数/2 临时变量传递.py b/11 概念认知/函数/2 临时变量传递.py index 6e68d86..0b7d0e3 100644 --- a/11 概念认知/函数/2 临时变量传递.py +++ b/11 概念认知/函数/2 临时变量传递.py @@ -17,14 +17,12 @@ def frequencies(word_list): def sort(word_freq): return sorted( word_freq.items(), key=lambda x: x[1], reverse=True ) -def printall(word_freqs, n = 10 ): - for word, freq in word_freqs[ :n ]: - print(word, '-', freq) - if __name__ == "__main__": txtcontent = read_file( testfilepath ) word_list = extractwords( txtcontent ) word_freqs = frequencies( word_list ) - word_sort = sort ( word_freqs ) - printall(word_sort) \ No newline at end of file + word_sorts = sort ( word_freqs ) + + for tf in word_sorts[:10]: + print(tf[0], '-', tf[1]) \ No newline at end of file diff --git a/12 语言特性/反射/tf_95.py b/12 语言特性/反射/反射_函数.py similarity index 100% rename from 12 语言特性/反射/tf_95.py rename to 12 语言特性/反射/反射_函数.py diff --git a/12 语言特性/反射/tf_94.py b/12 语言特性/反射/反射_类.py similarity index 100% rename from 12 语言特性/反射/tf_94.py rename to 12 语言特性/反射/反射_类.py diff --git a/12 语言特性/尾调用/tf-26.py b/12 语言特性/尾调用/模拟管道.py similarity index 100% rename from 12 语言特性/尾调用/tf-26.py rename to 12 语言特性/尾调用/模拟管道.py diff --git a/12 语言特性/异步.py b/12 语言特性/异步.py index fcd7c7f..5d12735 100644 --- a/12 语言特性/异步.py +++ b/12 语言特性/异步.py @@ -3,7 +3,7 @@ import aiofiles from collections import Counter from cppy.cp_util import * -########## 不太合适的一个场景 ###################### + # # 协程 # @@ -25,7 +25,7 @@ async def main(): top_words = await count_words(text) wordfreqs += top_words for word, count in wordfreqs.most_common(10): - print(f"{word}: {count//10}") + print(f"{word}: {count//10}") # 突出 Io 的提升价值 # 运行异步主函数 diff --git a/12 语言特性/装饰/自审装饰.py b/12 语言特性/装饰/反射装饰.py similarity index 100% rename from 12 语言特性/装饰/自审装饰.py rename to 12 语言特性/装饰/反射装饰.py diff --git a/13 计算设备/共享内存数据空间/30B.py b/13 计算设备/存储/内存队列_共享数据.py similarity index 100% rename from 13 计算设备/共享内存数据空间/30B.py rename to 13 计算设备/存储/内存队列_共享数据.py diff --git a/13 计算设备/共享内存数据空间/30A.py b/13 计算设备/存储/多线程_共享数据.py similarity index 93% rename from 13 计算设备/共享内存数据空间/30A.py rename to 13 计算设备/存储/多线程_共享数据.py index 8c53d46..d295b0a 100644 --- a/13 计算设备/共享内存数据空间/30A.py +++ b/13 计算设备/存储/多线程_共享数据.py @@ -1,6 +1,8 @@ import threading, queue from cppy.cp_util import * +# 能否简单的共享全局变量 ? + # 处理单词 def process_words(word_space, freq_space, stopwords): word_freqs = {} diff --git a/13 计算设备/数据库/ORM/DataQuery.py b/13 计算设备/存储/数据库/ORM/DataQuery.py similarity index 100% rename from 13 计算设备/数据库/ORM/DataQuery.py rename to 13 计算设备/存储/数据库/ORM/DataQuery.py diff --git a/13 计算设备/数据库/ORM/createDb.py b/13 计算设备/存储/数据库/ORM/createDb.py similarity index 100% rename from 13 计算设备/数据库/ORM/createDb.py rename to 13 计算设备/存储/数据库/ORM/createDb.py diff --git a/13 计算设备/数据库/ORM/processData.py b/13 计算设备/存储/数据库/ORM/processData.py similarity index 100% rename from 13 计算设备/数据库/ORM/processData.py rename to 13 计算设备/存储/数据库/ORM/processData.py diff --git a/13 计算设备/数据库/tf-26.py b/13 计算设备/存储/数据库/tf-26.py similarity index 100% rename from 13 计算设备/数据库/tf-26.py rename to 13 计算设备/存储/数据库/tf-26.py diff --git a/13 计算设备/任务平行分发/mapreduce.py b/13 计算设备/数据分包/mapreduce.py similarity index 100% rename from 13 计算设备/任务平行分发/mapreduce.py rename to 13 计算设备/数据分包/mapreduce.py diff --git a/13 计算设备/任务平行分发/多线程.py b/13 计算设备/数据分包/多线程.py similarity index 100% rename from 13 计算设备/任务平行分发/多线程.py rename to 13 计算设备/数据分包/多线程.py diff --git a/13 计算设备/任务平行分发/多进程.py b/13 计算设备/数据分包/多进程.py similarity index 100% rename from 13 计算设备/任务平行分发/多进程.py rename to 13 计算设备/数据分包/多进程.py diff --git a/13 计算设备/任务平行分发/抽象并发.py b/13 计算设备/数据分包/抽象并发.py similarity index 100% rename from 13 计算设备/任务平行分发/抽象并发.py rename to 13 计算设备/数据分包/抽象并发.py diff --git a/14 人机交互/桌面/tf-98.py b/14 人机交互/桌面/PyQT.py similarity index 100% rename from 14 人机交互/桌面/tf-98.py rename to 14 人机交互/桌面/PyQT.py diff --git a/14 人机交互/终端/终端菜单/tf-97.py b/14 人机交互/终端/终端菜单/terminal_menu.py similarity index 100% rename from 14 人机交互/终端/终端菜单/tf-97.py rename to 14 人机交互/终端/终端菜单/terminal_menu.py