//第三步,将名字提取出来,拼接成字符串(用逗号隔开) let result = "" realData.map(item=>{ let str = item.outerText; let index1 = str.indexOf('_'); let index2 = str.indexOf('_',index1+1); let res = str.slice(index1+1,index2); result += ',' + res; }) result = result.slice(1)
//第四步,用Blob对象包裹目标字符串,以URL的形式下载文件 var blob = newBlob([result]); var virtualLink = window.document.createElement('a'); virtualLink.href = URL.createObjectURL(blob); virtualLink.download = '名单'; window.document.body.appendChild(virtualLink); virtualLink.click(); window.document.body.removeChild(virtualLink);
Python
1 2 3 4 5
import pandas as pd
data = pd.read_table('名单.txt',sep=',',header=None) result = data.T result.to_excel('办事大厅申请留校名单.xlsx',index=False)