Python使用tablib生成excel文件的简单实现方法
作者:小谈博客 时间:2021-02-24 09:09:00
本文实例讲述了Python使用tablib生成excel文件的方法。分享给大家供大家参考,具体如下:
import tablib
headers = ('lie1', 'lie2', 'lie3', 'lie4', 'lie5')
mylist = [('23','23','34','23','34'),('sadf','23','sdf','23','fsad')]
mylist = tablib.Dataset(*mylist, headers=headers)
with open('excel.xlsx', 'wb') as f:
f.write(mylist.xlsx)
这是一个基本的最简单的使用tablib生成excel文件的示例,首先要安装tablib模块,在命令行输入:pip intall tablib,即可自动下载安装。
效果如图如下:
转自:小谈博客 http://www.tantengvip.com/2015/05/python-tablib-excel/
希望本文所述对大家Python程序设计有所帮助。
标签:Python,tablib,excel
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python基于随机采样一至性实现拟合椭圆
2022-11-25 01:44:35
![](https://img.aspxhome.com/file/2023/1/101641_0s.png)
Python实现Const详解
2021-06-24 16:18:40
Python实现从文件中加载数据的方法详解
2022-05-28 12:41:31
![](https://img.aspxhome.com/file/2023/0/107960_0s.png)
利用pip安装python第三方库的4种方法
2023-11-16 08:16:51
![](https://img.aspxhome.com/file/2023/0/63570_0s.png)
python怎么提高计算速度
2021-06-09 17:04:42
兼容Firefox的点击复制js代码
2008-08-28 12:17:00
PHP的mysqli_thread_id()函数讲解
2023-06-13 10:09:43
![](https://img.aspxhome.com/file/2023/3/55453_0s.png)
Python+腾讯云服务器实现每日自动健康打卡
2023-08-18 00:22:44
![](https://img.aspxhome.com/file/2023/8/70678_0s.png)
Python实现简易超市管理系统
2023-01-08 12:09:01
![](https://img.aspxhome.com/file/2023/2/94102_0s.png)
golang中select语句的简单实例
2023-09-03 03:01:28
![](https://img.aspxhome.com/file/2023/5/97165_0s.png)
python设计微型小说网站(基于Django+Bootstrap框架)
2023-03-15 01:54:18
![](https://img.aspxhome.com/file/2023/6/65046_0s.jpg)
php生成4位数字验证码的实现代码
2023-11-20 15:00:12
Python内存管理实例分析
2021-06-13 01:39:21
![](https://img.aspxhome.com/file/2023/5/97745_0s.png)
好习惯和坏习惯
2009-01-20 12:51:00
Python生成器与迭代器详情
2022-04-09 15:36:27
如何使Python中的print()语句运行结果不换行
2023-08-03 18:22:54
Python实现发送带有pdf附件的电子邮件
2022-02-01 14:08:05
![](https://img.aspxhome.com/file/2023/4/76924_0s.png)
python学习基础之循环import及import过程
2022-04-02 13:23:25
网页设计的十大戒律
2008-08-10 17:55:00
Django项目如何给数据库添加约束
2023-08-10 14:49:39
![](https://img.aspxhome.com/file/2023/4/62014_0s.jpg)