标签:file 中文名 type top position += 拼音 默认 一个
#!/usr/bin/python #-*-coding:utf-8-*- #指定编码格式,python默认unicode编码 from pypinyin import lazy_pinyin,Style import json,os,sys,shutil source_folder =r"G:\workspace\python\selenium\guji\gujisourse" def action(): file_list=os.listdir(source_folder) for file_obj in file_list: file_path=os.path.join(source_folder,file_obj) file_name,file_extend=os.path.splitext(file_obj) # print(file_name) new_name=file_name # print(new_name) my_new_name = [] # print(new_name) # print(type(new_name)) name = lazy_pinyin(new_name) result = ‘‘ for i in name: result +=i # print(result) # break result += file_extend # print(result) newfile_path=os.path.join(source_folder,result) shutil.copyfile(file_path,newfile_path) def run(): action() # s= lazy_pinyin(‘中心‘) # print(s) run()
标签:file 中文名 type top position += 拼音 默认 一个
原文地址:https://www.cnblogs.com/xixiaohui/p/12146390.html