Merge pull request #5 from jackfrued/master

update newest
This commit is contained in:
fanbiao 2021-03-28 09:43:50 +08:00 committed by GitHub
commit cd4edbb8a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
534 changed files with 48969 additions and 41824 deletions

View File

@ -316,7 +316,7 @@ if __name__ == '__main__':
但是切换作业是有代价的比如从语文切到数学要先收拾桌子上的语文书本、钢笔这叫保存现场然后打开数学课本、找出圆规直尺这叫准备新环境才能开始做数学作业。操作系统在切换进程或者线程时也是一样的它需要先保存当前执行的现场环境CPU寄存器状态、内存页等然后把新任务的执行环境准备好恢复上次的寄存器状态切换内存页等才能开始执行。这个切换过程虽然很快但是也需要耗费时间。如果有几千个任务同时进行操作系统可能就主要忙着切换任务根本没有多少时间去执行任务了这种情况最常见的就是硬盘狂响点窗口无反应系统处于假死状态。所以多任务一旦多到一个限度反而会使得系统性能急剧下降最终导致所有任务都做不好。
是否采用多任务的第二个考虑是任务的类型可以把任务分为计算密集型和I/O密集型。计算密集型任务的特点是要进行大量的计算消耗CPU资源比如对视频进行编码解码或者格式转换等等这种任务全靠CPU的运算能力虽然也可以用多任务完成但是任务越多花在任务切换的时间就越多CPU执行任务的效率就越低。计算密集型任务由于主要消耗CPU资源这类任务用Python这样的脚本语言去执行效率通常很低最能胜任这类任务的是C语言我们之前提到Python中有嵌入C/C++代码的机制。
是否采用多任务的第二个考虑是任务的类型可以把任务分为计算密集型和I/O密集型。计算密集型任务的特点是要进行大量的计算消耗CPU资源比如对视频进行编码解码或者格式转换等等这种任务全靠CPU的运算能力虽然也可以用多任务完成但是任务越多花在任务切换的时间就越多CPU执行任务的效率就越低。计算密集型任务由于主要消耗CPU资源这类任务用Python这样的脚本语言去执行效率通常很低最能胜任这类任务的是C语言我们之前提到Python中有嵌入C/C++代码的机制。
除了计算密集型任务其他的涉及到网络、存储介质I/O的任务都可以视为I/O密集型任务这类任务的特点是CPU消耗很少任务的大部分时间都在等待I/O操作完成因为I/O的速度远远低于CPU和内存的速度。对于I/O密集型任务如果启动多任务就可以减少I/O等待时间从而让CPU高效率的运转。有一大类的任务都属于I/O密集型任务这其中包括了我们很快会涉及到的网络应用和Web应用。
@ -324,9 +324,9 @@ if __name__ == '__main__':
### 单线程+异步I/O
现代操作系统对I/O操作的改进中最为重要的就是支持异步I/O。如果充分利用操作系统提供的异步I/O支持就可以用单进程单线程模型来执行多任务这种全新的模型称为事件驱动模型。Nginx就是支持异步I/O的Web服务器它在单核CPU上采用单进程模型就可以高效地支持多任务。在多核CPU上可以运行多个进程数量与CPU核心数相同充分利用多核CPU。用Node.js开发的服务器端程序也使用了这种工作模式这也是当下实现多任务编程的一种趋势
现代操作系统对I/O操作的改进中最为重要的就是支持异步I/O。如果充分利用操作系统提供的异步I/O支持就可以用单进程单线程模型来执行多任务这种全新的模型称为事件驱动模型。Nginx就是支持异步I/O的Web服务器它在单核CPU上采用单进程模型就可以高效地支持多任务。在多核CPU上可以运行多个进程数量与CPU核心数相同充分利用多核CPU。用Node.js开发的服务器端程序也使用了这种工作模式这也是当下并发编程的一种流行方案
在Python语言中单线程+异步I/O的编程模型称为协程有了协程的支持就可以基于事件驱动编写高效的多任务程序。协程最大的优势就是极高的执行效率因为子程序切换不是线程切换而是由程序自身控制因此没有线程切换的开销。协程的第二个优势就是不需要多线程的锁机制因为只有一个线程也不存在同时写变量冲突在协程中控制共享资源不用加锁只需要判断状态就好了所以执行效率比多线程高很多。如果想要充分利用CPU的多核特性最简单的方法是多进程+协程,既充分利用多核,又充分发挥协程的高效率,可获得极高的性能。关于这方面的内容,我稍后会做一个专题来进行讲解。
在Python语言中单线程+异步I/O的编程模型称为协程有了协程的支持就可以基于事件驱动编写高效的多任务程序。协程最大的优势就是极高的执行效率因为子程序切换不是线程切换而是由程序自身控制因此没有线程切换的开销。协程的第二个优势就是不需要多线程的锁机制因为只有一个线程也不存在同时写变量冲突在协程中控制共享资源不用加锁只需要判断状态就好了所以执行效率比多线程高很多。如果想要充分利用CPU的多核特性最简单的方法是多进程+协程,既充分利用多核,又充分发挥协程的高效率,可获得极高的性能。关于这方面的内容,在后续的课程中会进行讲解。
### 应用案例

View File

@ -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模块也能处理来自这些软件生成的电子表格。
```Python
import datetime
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws['A1'] = 42
ws.append([1, 2, 3])
ws['A2'] = datetime.datetime.now()
wb.save("sample.xlsx")
```
### 处理Word文档
利用python-docx模块Pytho 可以创建和修改Word文档当然这里的Word文档不仅仅是指通过微软的Office软件创建的扩展名为docx的文档LibreOffice Writer和OpenOffice Writer都是免费的字处理软件。
利用python-docx模块Python可以创建和修改Word文档当然这里的Word文档不仅仅是指通过微软的Office软件创建的扩展名为docx的文档LibreOffice Writer和OpenOffice Writer都是免费的字处理软件。
```Python
from docx import Document
from docx.shared import Inches
### 处理PDF文档
document = Document()
PDF是Portable Document Format的缩写使用.pdf作为文件扩展名。接下来我们就研究一下如何通过Python实现从PDF读取文本内容和从已有的文档生成新的PDF文件。
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')
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 515 KiB

After

Width:  |  Height:  |  Size: 412 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 KiB

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 171 KiB

View File

@ -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)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 B

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 640 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 474 B

After

Width:  |  Height:  |  Size: 334 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 KiB

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 395 B

After

Width:  |  Height:  |  Size: 260 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 744 B

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -102,7 +102,7 @@
// 查询垃圾分类的函数
search() {
if (this.word.trim().length > 0) {
let key = '9636cec76ee2593ba6b195e5b770b394'
let key = 'e8c5524dd2a365f20908ced735f8e480'
let url = `http://api.tianapi.com/txapi/lajifenlei/?key=${key}&word=${this.word}`
fetch(url)
.then(resp => resp.json())

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 KiB

After

Width:  |  Height:  |  Size: 314 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 246 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 201 KiB

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

@ -136,7 +136,7 @@ Linux系统的命令通常都是如下所示的格式
4. 清除屏幕上显示的内容 - **clear**
5. 查看帮助文档 - **man** / **info** / **help** / **apropos**
5. 查看帮助文档 - **man** / **info** / **--help** / **apropos**
```Shell
[root@izwz97tbgo9lkabnat2lo8z ~]# ps --help
Usage:
@ -230,7 +230,7 @@ Linux系统的命令通常都是如下所示的格式
[root@iZwz97tbgo9lkabnat2lo8Z ~]# !454
```
> 说明:查看到历史命令之后,可以用`!历史命令编号`来重新执行该命令;通过`history -c`可以清除历史命令。
> **说明**:查看到历史命令之后,可以用`!历史命令编号`来重新执行该命令;通过`history -c`可以清除历史命令。
### 实用程序
@ -308,7 +308,7 @@ Linux系统的命令通常都是如下所示的格式
...
```
> 说明:上面用到了一个名为`wget`的命令它是一个网络下载器程序可以从指定的URL下载资源。
> **说明**:上面用到了一个名为`wget`的命令它是一个网络下载器程序可以从指定的URL下载资源。
6. 拷贝/移动文件 - **cp** / **mv**
@ -350,7 +350,7 @@ Linux系统的命令通常都是如下所示的格式
52:</script>
...
```
> 说明:`grep`在搜索字符串时可以使用正则表达式,如果需要使用正则表达式可以用`grep -E`或者直接使用`egrep`。
> **说明**`grep`在搜索字符串时可以使用正则表达式,如果需要使用正则表达式可以用`grep -E`或者直接使用`egrep`。
9. 创建链接和查看链接 - **ln** / **readlink**
@ -372,7 +372,7 @@ Linux系统的命令通常都是如下所示的格式
CentOS Linux release 7.4.1708 (Core)
```
> 说明链接可以分为硬链接和软链接符号链接。硬链接可以认为是一个指向文件数据的指针就像Python中对象的引用计数每添加一个硬链接文件的对应链接数就增加1只有当文件的链接数为0时文件所对应的存储空间才有可能被其他文件覆盖。我们平常删除文件时其实并没有删除硬盘上的数据我们删除的只是一个指针或者说是数据的一条使用记录所以类似于“文件粉碎机”之类的软件在“粉碎”文件时除了删除文件指针还会在文件对应的存储区域填入数据来保证文件无法再恢复。软链接类似于Windows系统下的快捷方式当软链接链接的文件被删除时软链接也就失效了。
> **说明**链接可以分为硬链接和软链接符号链接。硬链接可以认为是一个指向文件数据的指针就像Python中对象的引用计数每添加一个硬链接文件的对应链接数就增加1只有当文件的链接数为0时文件所对应的存储空间才有可能被其他文件覆盖。我们平常删除文件时其实并没有删除硬盘上的数据我们删除的只是一个指针或者说是数据的一条使用记录所以类似于“文件粉碎机”之类的软件在“粉碎”文件时除了删除文件指针还会在文件对应的存储区域填入数据来保证文件无法再恢复。软链接类似于Windows系统下的快捷方式当软链接链接的文件被删除时软链接也就失效了。
10. 压缩/解压缩和归档/解归档 - **gzip** / **gunzip** / **xz**
@ -429,7 +429,7 @@ Linux系统的命令通常都是如下所示的格式
[root@iZwz97tbgo9lkabnat2lo8Z ~]# xargs < a.txt > b.txt
```
> 说明:这个命令就像上面演示的那样常在管道(实现进程间通信的一种方式)和重定向(重新指定输入输出的位置)操作中用到,后面的内容中会讲到管道操作和输入输出重定向操作。
> **说明**:这个命令就像上面演示的那样常在管道(实现进程间通信的一种方式)和重定向(重新指定输入输出的位置)操作中用到,后面的内容中会讲到管道操作和输入输出重定向操作。
13. 显示文件或目录 - **basename** / **dirname**
@ -751,7 +751,7 @@ Linux系统的命令通常都是如下所示的格式
设置hellokitty用户100天后必须修改密码过期前15天通知该用户过期后15天禁用该用户。
```Shell
chage -M 100 -W 15 -I 15 hellokitty
chage -M 100 -W 15 -I 7 hellokitty
```
5. 切换用户 - **su**
@ -954,7 +954,7 @@ Linux系统的命令通常都是如下所示的格式
8. 创建/激活/关闭交换分区 - **mkswap** / **swapon** / **swapoff**
> 说明:执行上面这些命令会带有一定的风险,如果不清楚这些命令的用法,最好不用随意使用,在使用的过程中,最好对照参考资料进行操作,并在操作前确认是否要这么做。
> **说明**:执行上面这些命令会带有一定的风险,如果不清楚这些命令的用法,最好不用随意使用,在使用的过程中,最好对照参考资料进行操作,并在操作前确认是否要这么做。
### 编辑器 - vim
@ -1788,6 +1788,8 @@ echo '结果: '$sum
```Shell
#!/usr/bin/bash
printf '输入文件夹名: '
read dir
printf '输入文件名: '
read file
printf '输入文件数量(<1000): '

Binary file not shown.

Before

Width:  |  Height:  |  Size: 220 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 179 KiB

View File

@ -551,9 +551,9 @@ MySQL在过去由于性能高、成本低、可靠性好已经成为最流行
```SQL
-- 插入学院数据
insert into tb_college (collname, collintro) values
('计算机学院', '创建于1956年是我国首批建立计算机专业。学院现有计算机科学与技术一级学科和网络空间安全一级学科博士学位授予权其中计算机科学与技术一级学科具有博士后流动站。计算机科学与技术一级学科在2017年全国第四轮学科评估中评为A2019 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
@ -836,7 +836,7 @@ possible_keys: NULL
在上面的SQL执行计划中有几项值得我们关注
1. typeMySQL在表中找到满足条件的行的方式也称为访问类型包括ALL全表扫描、index索引全扫描、range索引范围扫描、ref非唯一索引扫描、eq_ref唯一索引扫描、const/system、NULL。在所有的访问类型中很显然ALL是性能最差的它代表了全表扫描是指要扫描表中的每一行才能找到匹配的行。
1. `type`MySQL在表中找到满足条件的行的方式也称为访问类型包括ALL全表扫描、index索引全扫描、range索引范围扫描、ref非唯一索引扫描、eq_ref唯一索引扫描、const/system、NULL。在所有的访问类型中很显然ALL是性能最差的它代表了全表扫描是指要扫描表中的每一行才能找到匹配的行。
2. possible_keysMySQL可以选择的索引但是**有可能不会使用**。
3. keyMySQL真正使用的索引。
4. rows执行查询需要扫描的行数这是一个**预估值**。

Some files were not shown because too many files have changed in this diff Show More