import xlwt #读取目标文本文件 defget_str(path): f = open(path,encoding="utf-8") data = f.read() f.close() return data defsave_excel(save_path,sheetname,column_name_list,read_list): workbook = xlwt.Workbook() sheet1 = workbook.add_sheet(sheetname=sheetname) for i inrange(0,len(column_name_list)): sheet1.write(0,i,column_name_list[i]) i=1 for v in read_list: kval=v.split(':') for j inrange(0,len(kval)): sheet1.write(i+1,j,kval[j]) print(kval[j]) i=i+1
#保存为Excel文件 defsave_excel(save_path,sheetname,column_name_list,read_list): workbook = xlwt.Workbook() sheet1 = workbook.add_sheet(sheetname=sheetname) for i inrange(0,len(column_name_list)): sheet1.write(0,i,column_name_list[i]) i=1 for v in read_list: kval=v.split(':') for j inrange(0,len(kval)): sheet1.write(i+1,j,kval[j]) i=i+1 workbook.save(save_path) print('信息保存 OK,记录条数共计:'+str(len(read_list))) path=input("请输入文件路径:") save_path=input("请输入文件保存路径:") sheet_name=input("请输入sheetname:") column_name=input("请输入列名,并且使用英文逗号隔开:") column_name_list=column_name.split(',')
from translate import Translator translator = Translator(to_lang="Chinese") defget_str(path): f = open(path) data = f.read() f.close() return data path=input("请输入文件路径:") text=get_str(path) Virtual Group Coaching: How to Improve Group Relationships in Remote Work Settings translation = translator.translate(text) print(translation)
电话号码存储到 Excel 中
十、提取视频的音频信息
1 2 3
from moviepy.editor import AudioFileClip my_audio_clip = AudioFileClip("E:\PyVedio\py02.mp4") my_audio_clip.write_audiofile("E:\PyVedio\py02.wav")