1. 判断文件/文件夹是否存在
import os
if os.path.exists("test.txt"):
pass
2. 目录连接
import os
new_path = os.path.join(root_path, 'test.txt')
3. 创建目录
import os
os.mkdir(path)
4. 字典排序
word_list_order = sorted(word_dict.items(), key = lambda e:e[0], reverse = True) ##根据key降序
word_list_order = sorted(word_dict.items(), key = lambda e:e[1], reverse = True) ##根据value 降序
word_dict = { item[0]:item[1] for item in word_list_order} ## 恢复为字典