From 5f9b9a57d6b54abbf966555f007b36ea93e9ce0a Mon Sep 17 00:00:00 2001 From: jackfrued Date: Thu, 24 Sep 2020 07:36:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...07\346\241\243\345\244\204\347\220\206.md" | 67 ++++++++++- ...55\350\250\200\350\277\233\351\230\266.md" | 11 +- ...15\344\275\234\347\263\273\347\273\237.md" | 4 +- ...6\225\260\346\215\256\345\272\223MySQL.md" | 6 +- Day36-40/code/SRS_create_and_init.sql | 109 +++++++++--------- ...61\345\205\245\346\250\241\345\236\213.md" | 8 +- ...66\344\275\234\346\212\245\350\241\250.md" | 2 +- ...00\345\217\221\345\205\245\351\227\250.md" | 3 +- ...345\222\214DRF\345\205\245\351\227\250.md" | 39 +++---- ...345\222\214DRF\350\277\233\351\230\266.md" | 37 ++++++ ...32\346\227\266\344\273\273\345\212\241.md" | 2 + ...71\347\233\256\344\270\212\347\272\277.md" | 9 ++ ...60\346\215\256\346\216\245\345\217\243.md" | 2 + .../56.Flask\345\205\245\351\227\250.md" | 2 - ...77\347\232\204\344\275\277\347\224\250.md" | 2 - ...25\347\232\204\345\244\204\347\220\206.md" | 2 - ...56\345\272\223\346\223\215\344\275\234.md" | 2 - ...71\347\233\256\345\256\236\346\210\230.md" | 2 - ...04\345\274\202\346\255\245\345\214\226.md" | 2 +- ...06\345\222\214\350\247\243\346\236\220.md" | 6 +- ...50\346\200\201\345\206\205\345\256\271.md" | 80 ++++++++++++- ...47\350\203\275\344\274\230\345\214\226.md" | 3 +- ...06\344\270\232\351\241\271\347\233\256.md" | 12 +- ...47\350\203\275\350\260\203\344\274\230.md" | 13 +-- README.md | 15 +-- 25 files changed, 301 insertions(+), 139 deletions(-) create mode 100644 "Day56-60/56-60.\347\224\250FastAPI\345\274\200\345\217\221\346\225\260\346\215\256\346\216\245\345\217\243.md" delete mode 100644 "Day56-60/56.Flask\345\205\245\351\227\250.md" delete mode 100644 "Day56-60/57.\346\250\241\346\235\277\347\232\204\344\275\277\347\224\250.md" delete mode 100644 "Day56-60/58.\350\241\250\345\215\225\347\232\204\345\244\204\347\220\206.md" delete mode 100644 "Day56-60/59.\346\225\260\346\215\256\345\272\223\346\223\215\344\275\234.md" delete mode 100644 "Day56-60/60.\351\241\271\347\233\256\345\256\236\346\210\230.md" rename "Day61-65/63.\345\274\202\346\255\245\345\214\226.md" => "Day61-65/63.Tornado\344\270\255\347\232\204\345\274\202\346\255\245\345\214\226.md" (98%) diff --git "a/Day01-15/15.\345\233\276\345\203\217\345\222\214\345\212\236\345\205\254\346\226\207\346\241\243\345\244\204\347\220\206.md" "b/Day01-15/15.\345\233\276\345\203\217\345\222\214\345\212\236\345\205\254\346\226\207\346\241\243\345\244\204\347\220\206.md" index 765afa0..7ab5a80 100644 --- "a/Day01-15/15.\345\233\276\345\203\217\345\222\214\345\212\236\345\205\254\346\226\207\346\241\243\345\244\204\347\220\206.md" +++ "b/Day01-15/15.\345\233\276\345\203\217\345\222\214\345\212\236\345\205\254\346\226\207\346\241\243\345\244\204\347\220\206.md" @@ -110,13 +110,70 @@ Pillow中最为重要的是Image类,读取和处理图像都要通过这个类 ### 处理Excel电子表格 -Python的openpyxl模块让我们可以在Python程序中读取和修改Excel电子表格,当然实际工作中,我们可能会用LibreOffice Calc和OpenOffice Calc来处理Excel的电子表格文件,这就意味着openpyxl模块也能处理来自这些软件生成的电子表格。关于openpyxl的使用手册和使用文档可以查看它的[官方文档](https://openpyxl.readthedocs.io/en/stable/#)。 +Python的openpyxl模块让我们可以在Python程序中读取和修改Excel电子表格,由于微软从Office 2007开始使用了新的文件格式,这使得Office Excel和LibreOffice Calc、OpenOffice Calc是完全兼容的,这就意味着openpyxl模块也能处理来自这些软件生成的电子表格。 -### 处理Word文档 +```Python +import datetime -利用python-docx模块,Pytho 可以创建和修改Word文档,当然这里的Word文档不仅仅是指通过微软的Office软件创建的扩展名为docx的文档,LibreOffice Writer和OpenOffice Writer都是免费的字处理软件。 +from openpyxl import Workbook +wb = Workbook() +ws = wb.active -### 处理PDF文档 +ws['A1'] = 42 +ws.append([1, 2, 3]) +ws['A2'] = datetime.datetime.now() -PDF是Portable Document Format的缩写,使用.pdf作为文件扩展名。接下来我们就研究一下如何通过Python实现从PDF读取文本内容和从已有的文档生成新的PDF文件。 \ No newline at end of file +wb.save("sample.xlsx") +``` + +### 处理Word文档 + +利用python-docx模块,Python可以创建和修改Word文档,当然这里的Word文档不仅仅是指通过微软的Office软件创建的扩展名为docx的文档,LibreOffice Writer和OpenOffice Writer都是免费的字处理软件。 + +```Python +from docx import Document +from docx.shared import Inches + +document = Document() + +document.add_heading('Document Title', 0) + +p = document.add_paragraph('A plain paragraph having some ') +p.add_run('bold').bold = True +p.add_run(' and some ') +p.add_run('italic.').italic = True + +document.add_heading('Heading, level 1', level=1) +document.add_paragraph('Intense quote', style='Intense Quote') + +document.add_paragraph( + 'first item in unordered list', style='List Bullet' +) +document.add_paragraph( + 'first item in ordered list', style='List Number' +) + +document.add_picture('monty-truth.png', width=Inches(1.25)) + +records = ( + (3, '101', 'Spam'), + (7, '422', 'Eggs'), + (4, '631', 'Spam, spam, eggs, and spam') +) + +table = document.add_table(rows=1, cols=3) +hdr_cells = table.rows[0].cells +hdr_cells[0].text = 'Qty' +hdr_cells[1].text = 'Id' +hdr_cells[2].text = 'Desc' +for qty, id, desc in records: + row_cells = table.add_row().cells + row_cells[0].text = str(qty) + row_cells[1].text = id + row_cells[2].text = desc + +document.add_page_break() + +document.save('demo.docx') +``` diff --git "a/Day16-20/16-20.Python\350\257\255\350\250\200\350\277\233\351\230\266.md" "b/Day16-20/16-20.Python\350\257\255\350\250\200\350\277\233\351\230\266.md" index 111f2f5..abdf665 100644 --- "a/Day16-20/16-20.Python\350\257\255\350\250\200\350\277\233\351\230\266.md" +++ "b/Day16-20/16-20.Python\350\257\255\350\250\200\350\277\233\351\230\266.md" @@ -792,11 +792,11 @@ Python使用了自动化内存管理,这种管理机制以**引用计数**为基础,同时也引入了**标记-清除**和**分代收集**两种机制为辅的策略。 ```C - typedef struct_object { + typedef struct _object { /* 引用计数 */ int ob_refcnt; /* 对象指针 */ - struct_typeobject *ob_type; + struct _typeobject *ob_type; } PyObject; ``` @@ -1166,12 +1166,12 @@ Python中实现并发编程的三种方案:多线程、多进程和异步I/O import threading - class Account(): + class Account: """银行账户""" def __init__(self, balance=0): self.balance = balance - lock = threading.Lock() + lock = threading.RLock() self.condition = threading.Condition(lock) def withdraw(self, money): @@ -1212,9 +1212,10 @@ Python中实现并发编程的三种方案:多线程、多进程和异步I/O def main(): account = Account() - with ThreadPoolExecutor(max_workers=10) as pool: + with ThreadPoolExecutor(max_workers=15) as pool: for _ in range(5): pool.submit(add_money, account) + for _ in range(10): pool.submit(sub_money, account) diff --git "a/Day31-35/31-35.\347\216\251\350\275\254Linux\346\223\215\344\275\234\347\263\273\347\273\237.md" "b/Day31-35/31-35.\347\216\251\350\275\254Linux\346\223\215\344\275\234\347\263\273\347\273\237.md" index 9310363..ea59ac0 100644 --- "a/Day31-35/31-35.\347\216\251\350\275\254Linux\346\223\215\344\275\234\347\263\273\347\273\237.md" +++ "b/Day31-35/31-35.\347\216\251\350\275\254Linux\346\223\215\344\275\234\347\263\273\347\273\237.md" @@ -136,7 +136,7 @@ Linux系统的命令通常都是如下所示的格式: 4. 清除屏幕上显示的内容 - **clear**。 -5. 查看帮助文档 - **man** / **info** / **help** / **apropos**。 +5. 查看帮助文档 - **man** / **info** / **--help** / **apropos**。 ```Shell [root@izwz97tbgo9lkabnat2lo8z ~]# ps --help Usage: @@ -1788,6 +1788,8 @@ echo '结果: '$sum ```Shell #!/usr/bin/bash +printf '输入文件夹名: ' +read dir printf '输入文件名: ' read file printf '输入文件数量(<1000): ' diff --git "a/Day36-40/36-38.\345\205\263\347\263\273\345\236\213\346\225\260\346\215\256\345\272\223MySQL.md" "b/Day36-40/36-38.\345\205\263\347\263\273\345\236\213\346\225\260\346\215\256\345\272\223MySQL.md" index 0ea1c79..8b2b48d 100644 --- "a/Day36-40/36-38.\345\205\263\347\263\273\345\236\213\346\225\260\346\215\256\345\272\223MySQL.md" +++ "b/Day36-40/36-38.\345\205\263\347\263\273\345\236\213\346\225\260\346\215\256\345\272\223MySQL.md" @@ -551,9 +551,9 @@ MySQL在过去由于性能高、成本低、可靠性好,已经成为最流行 ```SQL -- 插入学院数据 insert into tb_college (collname, collintro) values - ('计算机学院', '创建于1956年是我国首批建立计算机专业。学院现有计算机科学与技术一级学科和网络空间安全一级学科博士学位授予权,其中计算机科学与技术一级学科具有博士后流动站。计算机科学与技术一级学科在2017年全国第四轮学科评估中评为A;2019 U.S.News全球计算机学科排名26名;ESI学科排名0.945‰,进入全球前1‰,位列第43位。'), - ('外国语学院', '1998年浙江大学、杭州大学、浙江农业大学、浙江医科大学四校合并,成立新的浙江大学。1999年原浙江大学外语系、原杭州大学外国语学院、原杭州大学大外部、原浙江农业大学公外部、原浙江医科大学外语教学部合并,成立浙江大学外国语学院。2003年学院更名为浙江大学外国语言文化与国际交流学院。'), - ('经济管理学院', '四川大学经济学院历史悠久、传承厚重,其前身是创办于1905年的四川大学经济科,距今已有100多年的历史。已故著名经济学家彭迪先、张与九、蒋学模、胡寄窗、陶大镛、胡代光,以及当代著名学者刘诗白等曾先后在此任教或学习。在长期的办学过程中,学院坚持以马克思主义的立场、观点、方法为指导,围绕建设世界一流经济学院的奋斗目标,做实“两个伟大”深度融合,不断提高党的建设质量与科学推进一流事业深度融合。'); + ('计算机学院', '计算机学院1958年设立计算机专业,1981年建立计算机科学系,1998年设立计算机学院,2005年5月,为了进一步整合教学和科研资源,学校决定,计算机学院和软件学院行政班子合并统一运作、实行教学和学生管理独立运行的模式。 学院下设三个系:计算机科学与技术系、物联网工程系、计算金融系;两个研究所:图象图形研究所、网络空间安全研究院(2015年成立);三个教学实验中心:计算机基础教学实验中心、IBM技术中心和计算机专业实验中心。'), + ('外国语学院', '四川大学外国语学院设有7个教学单位,6个文理兼收的本科专业;拥有1个一级学科博士授予点,3个二级学科博士授予点,5个一级学科硕士学位授权点,5个二级学科硕士学位授权点,5个硕士专业授权领域,同时还有2个硕士专业学位(MTI)专业;有教职员工210余人,其中教授、副教授80余人,教师中获得中国国内外名校博士学位和正在职攻读博士学位的教师比例占专任教师的60%以上。'), + ('经济管理学院', '四川大学经济学院前身是创办于1905年的四川大学经济科;已故经济学家彭迪先、张与九、蒋学模、胡寄窗、陶大镛、胡代光,以及当代学者刘诗白等曾先后在此任教或学习;1905年,四川大学设经济科;1924年,四川大学经济系成立;1998年,四川大学经济管理学院变更为四川大学经济学院。'); -- 插入学生数据 insert into tb_student (stuid, stuname, stusex, stubirth, stuaddr, collid) values diff --git a/Day36-40/code/SRS_create_and_init.sql b/Day36-40/code/SRS_create_and_init.sql index 301c7bc..637e514 100644 --- a/Day36-40/code/SRS_create_and_init.sql +++ b/Day36-40/code/SRS_create_and_init.sql @@ -2,7 +2,7 @@ drop database if exists school; -- 创建名为school的数据库并设置默认的字符集和排序方式 -create database school default charset utf8 collate utf8_bin; +create database school default charset utf8; -- 切换到school数据库上下文环境 use school; @@ -10,35 +10,32 @@ use school; -- 创建学院表 create table tb_college ( -collid int not null auto_increment comment '编号', -collname varchar(50) not null comment '名称', -collmaster varchar(20) not null comment '院长', -collweb varchar(511) default '' comment '网站', +collid int auto_increment comment '编号', +collname varchar(50) not null comment '名称', +collintro varchar(500) default '' comment '介绍', primary key (collid) ); -- 创建学生表 create table tb_student ( -stuid int not null comment '学号', -stuname varchar(20) not null comment '姓名', -stusex bit default 1 comment '性别', -stubirth date not null comment '出生日期', -stuaddr varchar(255) default '' comment '籍贯', -collid int not null comment '所属学院', +stuid int not null comment '学号', +stuname varchar(20) not null comment '姓名', +stusex boolean default 1 comment '性别', +stubirth date not null comment '出生日期', +stuaddr varchar(255) default '' comment '籍贯', +collid int not null comment '所属学院', primary key (stuid), foreign key (collid) references tb_college (collid) ); --- alter table tb_student add constraint fk_student_collid foreign key (collid) references tb_college (collid); - -- 创建教师表 create table tb_teacher ( -teaid int not null comment '工号', -teaname varchar(20) not null comment '姓名', -teatitle varchar(10) default '助教' comment '职称', -collid int not null comment '所属学院', +teaid int not null comment '工号', +teaname varchar(20) not null comment '姓名', +teatitle varchar(10) default '助教' comment '职称', +collid int not null comment '所属学院', primary key (teaid), foreign key (collid) references tb_college (collid) ); @@ -46,48 +43,54 @@ foreign key (collid) references tb_college (collid) -- 创建课程表 create table tb_course ( -couid int not null comment '编号', -couname varchar(50) not null comment '名称', -coucredit int not null comment '学分', -teaid int not null comment '授课老师', +couid int not null comment '编号', +couname varchar(50) not null comment '名称', +coucredit int not null comment '学分', +teaid int not null comment '授课老师', primary key (couid), foreign key (teaid) references tb_teacher (teaid) ); -- 创建选课记录表 -create table tb_score +create table tb_record ( -scid int auto_increment comment '选课记录编号', -stuid int not null comment '选课学生', -couid int not null comment '所选课程', -scdate datetime comment '选课时间日期', -scmark decimal(4,1) comment '考试成绩', -primary key (scid), -foreign key (stuid) references tb_student (stuid), -foreign key (couid) references tb_course (couid) +recid int auto_increment comment '选课记录编号', +sid int not null comment '选课学生', +cid int not null comment '所选课程', +seldate datetime default now() comment '选课时间日期', +score decimal(4,1) comment '考试成绩', +primary key (recid), +foreign key (sid) references tb_student (stuid), +foreign key (cid) references tb_course (couid), +unique (sid, cid) ); --- 添加唯一性约束(一个学生选某个课程只能选一次) -alter table tb_score add constraint uni_score_stuid_couid unique (stuid, couid); - -- 插入学院数据 -insert into tb_college (collname, collmaster, collweb) values -('计算机学院', '左冷禅', 'http://www.abc.com'), -('外国语学院', '岳不群', 'http://www.xyz.com'), -('经济管理学院', '风清扬', 'http://www.foo.com'); +insert into tb_college (collname, collintro) values +('计算机学院', '计算机学院1958年设立计算机专业,1981年建立计算机科学系,1998年设立计算机学院,2005年5月,为了进一步整合教学和科研资源,学校决定,计算机学院和软件学院行政班子合并统一运作、实行教学和学生管理独立运行的模式。 学院下设三个系:计算机科学与技术系、物联网工程系、计算金融系;两个研究所:图象图形研究所、网络空间安全研究院(2015年成立);三个教学实验中心:计算机基础教学实验中心、IBM技术中心和计算机专业实验中心。'), +('外国语学院', '四川大学外国语学院设有7个教学单位,6个文理兼收的本科专业;拥有1个一级学科博士授予点,3个二级学科博士授予点,5个一级学科硕士学位授权点,5个二级学科硕士学位授权点,5个硕士专业授权领域,同时还有2个硕士专业学位(MTI)专业;有教职员工210余人,其中教授、副教授80余人,教师中获得中国国内外名校博士学位和正在职攻读博士学位的教师比例占专任教师的60%以上。'), +('经济管理学院', '四川大学经济学院前身是创办于1905年的四川大学经济科;已故经济学家彭迪先、张与九、蒋学模、胡寄窗、陶大镛、胡代光,以及当代学者刘诗白等曾先后在此任教或学习;1905年,四川大学设经济科;1924年,四川大学经济系成立;1998年,四川大学经济管理学院变更为四川大学经济学院。'); -- 插入学生数据 -insert into tb_student (stuid, stuname, stusex, stubirth, stuaddr, collid) values -(1001, '杨逍', 1, '1990-3-4', '四川成都', 1), -(1002, '任我行', 1, '1992-2-2', '湖南长沙', 1), -(1033, '王语嫣', 0, '1989-12-3', '四川成都', 1), -(1572, '岳不群', 1, '1993-7-19', '陕西咸阳', 1), -(1378, '纪嫣然', 0, '1995-8-12', '四川绵阳', 1), -(1954, '林平之', 1, '1994-9-20', '福建莆田', 1), -(2035, '东方不败', 1, '1988-6-30', null, 2), -(3011, '林震南', 1, '1985-12-12', '福建莆田', 3), -(3755, '项少龙', 1, '1993-1-25', null, 3), -(3923, '杨不悔', 0, '1985-4-17', '四川成都', 3); +insert into tb_student (stuid, stuname, stusex, stubirth, stuaddr, collid) +values + (1001, '杨逍', 1, '1990-3-4', '四川成都', 1), + (1002, '任我行', 1, '1992-2-2', '湖南长沙', 1), + (1033, '王语嫣', 0, '1989-12-3', '四川成都', 1), + (1572, '岳不群', 1, '1993-7-19', '陕西咸阳', 1), + (1378, '纪嫣然', 0, '1995-8-12', '四川绵阳', 1), + (1954, '林平之', 1, '1994-9-20', '福建莆田', 1), + (2035, '东方不败', 1, '1988-6-30', null, 2), + (3011, '林震南', 1, '1985-12-12', '福建莆田', 3), + (3755, '项少龙', 1, '1993-1-25', null, 3), + (3923, '杨不悔', 0, '1985-4-17', '四川成都', 3), + (4040, '炼腰的隔壁老王', 1, '1989-1-1', '四川成都', 2); + +-- 删除学生数据 +delete from tb_student where stuid=4040; + +-- 更新学生数据 +update tb_student set stuname='杨过', stuaddr='湖南长沙' where stuid=1001; -- 插入老师数据 insert into tb_teacher (teaid, teaname, teatitle, collid) values @@ -110,7 +113,7 @@ insert into tb_course (couid, couname, coucredit, teaid) values (9999, '审计学', 3, 3366); -- 插入选课数据 -insert into tb_score (stuid, couid, scdate, scmark) values +insert into tb_record (sid, cid, seldate, score) values (1001, 1111, '2017-09-01', 95), (1001, 2222, '2017-09-01', 87.5), (1001, 3333, '2017-09-01', 100), @@ -125,9 +128,9 @@ insert into tb_score (stuid, couid, scdate, scmark) values (1378, 1111, '2017-09-05', 82), (1378, 7777, '2017-09-02', 65.5), (2035, 7777, '2018-09-03', 88), -(2035, 9999, curdate(), null), -(3755, 1111, date(now()), null), -(3755, 8888, date(now()), null), +(2035, 9999, default, null), +(3755, 1111, default, null), +(3755, 8888, default, null), (3755, 9999, '2017-09-01', 92); -- 查询所有学生信息 @@ -227,8 +230,6 @@ select stuname, couname, scmark from tb_student t1 inner join tb_score t3 on t1. select stuname, couname, scmark from tb_student t1 inner join tb_score t3 on t1.stuid=t3.stuid inner join tb_course t2 on t2.couid=t3.couid where scmark is not null order by scmark desc limit 10, 5; --- 单表:65535TB --- 单列:4G - LONGBLOB (Binary Large OBject) / LONGTEXT -- 查询选课学生的姓名和平均成绩(子查询和连接查询) select stuname, avgmark from tb_student t1, (select stuid, avg(scmark) as avgmark from tb_score group by stuid) t2 where t1.stuid=t2.stuid; diff --git "a/Day41-55/42.\346\267\261\345\205\245\346\250\241\345\236\213.md" "b/Day41-55/42.\346\267\261\345\205\245\346\250\241\345\236\213.md" index 0d2a7c7..dc9b86b 100644 --- "a/Day41-55/42.\346\267\261\345\205\245\346\250\241\345\236\213.md" +++ "b/Day41-55/42.\346\267\261\345\205\245\346\250\241\345\236\213.md" @@ -132,8 +132,6 @@ class Meta: managed = False db_table = 'tb_subject' - verbose_name = '学科' - verbose_name_plural = '学科' class Teacher(models.Model): @@ -151,7 +149,7 @@ managed = False db_table = 'tb_teacher' ``` - + > **说明**:模型类都直接或间接继承自`Model`类,模型类跟关系型数据库的二维表对应,模型对象跟表中的记录对应,模型对象的属性跟表中的字段对应。如果对上面模型类的属性定义不是特别理解,可以看看本文后面提供的“模型定义参考”部分的内容。 ### 使用ORM完成模型的CRUD操作 @@ -205,6 +203,8 @@ Subject.objects.filter(name='Python全栈+人工智能') # 查询名称包含“全栈”的学科(模糊查询) Subject.objects.filter(name__contains='全栈') +Subject.objects.filter(name__startswith='全栈') +Subject.objects.filter(name__endswith='全栈') # 查询所有热门学科 Subject.objects.filter(is_hot=True) @@ -513,7 +513,7 @@ Teacher.objects.filter(subject__name__contains='全栈')
姓名:{{ teacher.name }} 性别:{{ teacher.sex | yesno:'男,女' }} - 出生日期:{{ teacher.birth }} + 出生日期:{{ teacher.birth | date:'Y年n月j日'}}
{{ teacher.intro }}
diff --git "a/Day41-55/45.\345\210\266\344\275\234\346\212\245\350\241\250.md" "b/Day41-55/45.\345\210\266\344\275\234\346\212\245\350\241\250.md" index ecf9c6b..12d728b 100644 --- "a/Day41-55/45.\345\210\266\344\275\234\346\212\245\350\241\250.md" +++ "b/Day41-55/45.\345\210\266\344\275\234\346\212\245\350\241\250.md" @@ -8,7 +8,7 @@ 报表 = 多样的格式 + 动态的数据 ``` -有很多的三方库支持在Python程序中写Excel文件,包括[`xlwt`]()、[`xlwings`]()、[`openpyxl`]()、[`xlswriter`]()、[`pandas`]()等,其中的xlwt虽然只支持写xls格式的Excel文件,但在性能方面的表现还是不错的。下面我们就以`xlwt`为例,来演示如何在Django项目中导出Excel报表。 +有很多的三方库支持在Python程序中写Excel文件,包括[`xlwt`]()、[`xlwings`]()、[`openpyxl`]()、[`xlswriter`]()等,其中的xlwt虽然只支持写xls格式的Excel文件,但在性能方面的表现还是不错的。下面我们就以`xlwt`为例,来演示如何在Django项目中导出Excel报表。 安装`xlwt`。 diff --git "a/Day41-55/48.\345\211\215\345\220\216\347\253\257\345\210\206\347\246\273\345\274\200\345\217\221\345\205\245\351\227\250.md" "b/Day41-55/48.\345\211\215\345\220\216\347\253\257\345\210\206\347\246\273\345\274\200\345\217\221\345\205\245\351\227\250.md" index 0675a75..bd41eaa 100644 --- "a/Day41-55/48.\345\211\215\345\220\216\347\253\257\345\210\206\347\246\273\345\274\200\345\217\221\345\205\245\351\227\250.md" +++ "b/Day41-55/48.\345\211\215\345\220\216\347\253\257\345\210\206\347\246\273\345\274\200\345\217\221\345\205\245\351\227\250.md" @@ -174,4 +174,5 @@ class SubjectMapper(ModelMapper): 前后端分离的开发需要将前端页面作为静态资源进行部署,项目实际上线的时候,我们会对整个Web应用进行动静分离,静态资源通过Nginx或Apache服务器进行部署,生成动态内容的Python程序部署在uWSGI或者Gunicorn服务器上,对动态内容的请求由Nginx或Apache路由到uWSGI或Gunicorn服务器上。 -在开发阶段,我们通常会使用Django自带的测试服务器,如果要尝试前后端分离,可以先将静态页面放在之前创建的放静态资源的目录下,具体的做法可以参考[项目完整代码](https://gitee.com/jackfrued/django19062)。 \ No newline at end of file +在开发阶段,我们通常会使用Django自带的测试服务器,如果要尝试前后端分离,可以先将静态页面放在之前创建的放静态资源的目录下,具体的做法可以参考[项目完整代码](https://gitee.com/jackfrued/django19062)。 + diff --git "a/Day41-55/49.RESTful\346\236\266\346\236\204\345\222\214DRF\345\205\245\351\227\250.md" "b/Day41-55/49.RESTful\346\236\266\346\236\204\345\222\214DRF\345\205\245\351\227\250.md" index 04eb692..effe463 100644 --- "a/Day41-55/49.RESTful\346\236\266\346\236\204\345\222\214DRF\345\205\245\351\227\250.md" +++ "b/Day41-55/49.RESTful\346\236\266\346\236\204\345\222\214DRF\345\205\245\351\227\250.md" @@ -170,7 +170,7 @@ urlpatterns = [

{{ subject.name }}学科的老师信息


-

暂无该学科老师信息

+

暂无该学科老师信息

@@ -183,23 +183,24 @@ urlpatterns = [
{{ teacher.intro }}
- 好评   + 好评   ({{ teacher.good_count }})      - 差评   + 差评   ({{ teacher.bad_count }})
- 返回首页 + 返回首页