1、pip 重新安装, 镜像源设置,安装其他库
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple2、numpy矩阵运算 3、matplotlib绘图 4、requests/bs4网络下载图片 Python 爬虫系列教程一爬取批量百度图片 5、jieba统计字频
counts = {"名字":"3"} print(counts.get("名字", 0)) #3 import jieba txt = open("D://Python3.8//theyn//text//ceshi.txt", "r").read()#读取txt文件的所有内容到字符串str中 words = jieba.lcut(txt) # 使用精确模式对文本进行分词 print(words) counts = {} # 通过键值对的形式存储词语及其出现的次数 for word in words: if len(word) == 1: # 单个词语不计算在内 continue else: counts[word] = counts.get(word, 0) + 1 # 遍历所有词语,每出现一次其对应的值加 1 items = list(counts.items())#将键值对转换成列表 items.sort(key=lambda x: x[1], reverse=True) # 根据词语出现的次数进行从大到小排序 for i in range(3): word, count = items[i] print("{0:<5}{1:>5}".format(word, count))定义数组 修改文件夹名称os.rename() 元组()与列表[],元组不能修改 索引与截取[:],正向,反向 获取当前工作目录os.getcwd()
