1.如何获取中文字符串的首字母
import pinyin #输入name def get_pinyin_first_alpha(name): return "".join([i[0] for i in pinyin.get(name, " ").split(" ")])
2. 判断文件夹是否存在, 存在删除,不存在创建
import os import shutil def create_folder(train_data_path ): if os.path.exists(train_data_path): shutil.rmtree(train_data_path) os.mkdir(train_data_path)