python快速建造一个表格

import openpyxl
wb=openpyxl.Workbook()  
#创建工作簿
sheet=wb.active 
sheet1=wb.active 
sheet2=wb.active 
#获取工作簿的活动表
sheet.title='暗影精灵5代HP' 
sheet1.title = 'HP惠普光影精灵6'
sheet2.title = 'HP惠普暗影精灵5游戏本2'
#工作表重命名

sheet['A1'] ='歌曲名'     #加表头,给A1单元格赋值
sheet['B1'] ='所属专辑'   #加表头,给B1单元格赋值
sheet['C1'] ='播放时长'   #加表头,给C1单元格赋值
sheet['D1'] ='播放链接'   #加表头,给D1单元格赋值


# 查找播放链接,把链接赋值给link
for i in range(10):
    sheet.append(['name','album','time','link'])

wb.save('a.xlsx')            
#最后保存并命名这个Excel文件

posted @ 2021-07-14 17:55  pywjh  阅读(671)  评论(0编辑  收藏  举报
回到顶部