当前位置: 首页 > news >正文

Linux shell编程学习笔记80:gzip命令——让文件瘦身

0 引言

Linux shell编程学习笔记76:tar命令——快照 & 备份(上)-CSDN博客

Linux shell编程学习笔记77:tar命令——快照 & 备份(下)_linux 系统快照-CSDN博客 

Linux shell编程学习笔记78:cpio命令——文件和目录归档工具(上)-CSDN博客

Linux shell编程学习笔记79:cpio命令——文件和目录归档工具(下)-CSDN博客

中,我们分别介绍了用于文件和目录归档的tar和cpio命令,为了缩小归档文件的体积,我们还可以使用压缩软件对归档文件进行压缩。

在Windows系统中,我们常用的压缩软件有WinRAR、7-Zip、WinZip、PeaZip、Bandizip等。

在Linux系统中,常用的压缩软件有gzip,plzip、p7zip、pbzip2、ebzip等。

今天我们重点研究gzip。

1 gzip 的功能,帮助信息,格式,选项和参数说明

1.1 gzip 的功能

gzip 命令是 Linux 中流行的压缩工具,用于减小文件大小,同时保留其原始内容。它是 GNU Core Utilities 包的一部分,几乎在所有 Linux 发行版上都可用。 

1.2 gzip 的帮助信息

我们可以使用 gzip -h 命令获取帮助信息。

1.2.1 bash中的gzip帮助信息

[purpleendurer @ bash ~] gzip
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h
[purpleendurer @ bash ~] gzip -h
Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place).Mandatory arguments to long options are mandatory for short options too.-c, --stdout      write on standard output, keep original files unchanged-d, --decompress  decompress-f, --force       force overwrite of output file and compress links-h, --help        give this help-l, --list        list compressed file contents-L, --license     display software license-n, --no-name     do not save or restore the original name and time stamp-N, --name        save or restore the original name and time stamp-q, --quiet       suppress all warnings-r, --recursive   operate recursively on directories-S, --suffix=SUF  use suffix SUF on compressed files-t, --test        test compressed file integrity-v, --verbose     verbose mode-V, --version     display version number-1, --fast        compress faster-9, --best        compress better--rsyncable   Make rsync-friendly archiveWith no FILE, or when FILE is -, read standard input.Report bugs to <bug-gzip@gnu.org>.
[purpleendurer @ bash ~] 

 1.2.2 银河麒麟(kylin)系统中的gzip帮助信息

[purpleendurer @ kylin ~] gzip -h
Usage: gzip [OPTION]... [FILE]...
Compress or uncompress FILEs (by default, compress FILES in-place).Mandatory arguments to long options are mandatory for short options too.-c, --stdout      write on standard output, keep original files unchanged-d, --decompress  decompress-f, --force       force overwrite of output file and compress links-h, --help        give this help-k, --keep        keep (don't delete) input files-l, --list        list compressed file contents-L, --license     display software license-n, --no-name     do not save or restore the original name and time stamp-N, --name        save or restore the original name and time stamp-q, --quiet       suppress all warnings-r, --recursive   operate recursively on directories-S, --suffix=SUF  use suffix SUF on compressed files-t, --test        test compressed file integrity-v, --verbose     verbose mode-V, --version     display version number-1, --fast        compress faster-9, --best        compress better--rsyncable       Make rsync-friendly archiveWith no FILE, or when FILE is -, read standard input.Report bugs to <bug-gzip@gnu.org>.
[purpleendurer @ kylin ~] 

 

1.3 gzip 的命令格式

gzip [选项]... [文件]...

1.4 gzip 的选项和参数说明

1.4.1 gzip的选项

选项说明备注
-c, --stdout写入标准输出,保持原始文件不变
-d, --decompress解压缩
-f, --force强制覆盖输出文件并压缩链接
-h, --help提供此帮助信息
-k, --keep保留(不删除)输入文件

不是所有版本的gzip都支持此参数

已知1.5不支持,1.6支持

-l, --list列出压缩文件内容
-L, --license显示软件许可证
-n, --no-name不保存或恢复原始名称和时间戳
-N, --name保存或恢复原始名称和时间戳
-q, --quiet抑制所有警告
-r、--recursive对目录递归操作
-S, --suffix=SUF在压缩文件上使用后缀 SUF
-t, --test测试压缩文件的完整性建议同时指定-v选项
-v, --verbose详细模式,显示详细的压缩或解压缩过程
-V、--version显示版本号
-1, --fast压缩速度更快
-9, --best压缩得更好
--rsyncable制作 rsync 友好的存档

1.4.2 gzip的参数

文件:表示要压缩或解压缩的一个或多个文件。 

2 gzip使用实例

2.1 创建演示文件和目录

我们使用 echo 命令和输出重定向创建文件f1.txt 和 f2.txt,使用mkdir命令创建目录d1,再使用 echo 命令和输出重定向在目录d1下面创建文件fa.txt 和 fb.txt
 

[purpleendurer @ bash ~ ] echo "f1" > f1.txt
[purpleendurer @ bash ~ ] echo "f2" > f2.txt
[purpleendurer @ bash ~ ] mkdir d1
[purpleendurer @ bash ~ ] echo "d1fa" > d1/fa.txt
[purpleendurer @ bash ~ ] echo "d1fb" > d1/fb.txt
[purpleendurer @ bash ~ ] ls -R
.:
Code  d1  f1.txt  f2.txt./Code:./d1:
fa.txt  fb.txt
[purpleendurer @ bash ~ ] 

 

2.2 压缩单个文件

2.2.1 压缩单个文件后删除源文件  

例如:使用gzip压缩当前目录下文件f1.txt的命令 :gzip f1.txt 

[purpleendurer @ bash ~ ] ls
Code  d1  f1.txt  f2.txt
[purpleendurer @ bash ~ ] gzip f1.txt
[purpleendurer @ bash ~ ] ls
Code  d1  f1.txt.gz  f2.txt
[purpleendurer @ bash ~ ] 

执行压缩命令后,我们会发现在当前目录下,被压缩的源文件f1.txt不见了,多了一个压缩后的目标文件 f1.txt.gz。

注意:在默认情况下,gzip压缩指定的文件,并为它加上 .gz 扩展名。源文件会被删除。 

2.2.2 压缩单个文件后保留源文件  

如果我们希望压缩文件后仍然保留源文件,该如何操作呢?

例如使用gzip压缩当前目录下文件f2.txt,压缩后不删除f2.tx

如果我们使用的gzip支持-k 选项,那么可以使用 -k 选项,命令为 :

gzip -k f2.txt 

如果我们使用的gzip不支持-k 选项,那么可以使用-c选项结合输出重定向来操作,命令为:

gzip -c f2.txt > f2.txt.gz

[purpleendurer @ bash ~ ] ls
Code  d1  f1.txt.gz  f2.txt
[purpleendurer @ bash ~ ] gzip -k f2.txt
gzip: invalid option -- 'k'
Try `gzip --help' for more information.
[purpleendurer @ bash ~ ] gzip -c f2.txt > f2.txt.gz
gzip: f2.txt : No such file or directory
[purpleendurer @ bash ~ ] ls
Code  d1  f1.txt.gz  f2.txt  f2.txt.gz
[purpleendurer @ bash ~ ] 

在上面的操作中,我们先尝试了命令: gzip -k f2.txt ,但是很不幸的是,我们使用的gzip不支持-k选项。

接着我们尝试了命令:gzip -c f2.txt > f2.txt.gz,虽然我们收到了出错提示信息:

gzip: f2.txt : No such file or directory

但是,我们使用ls命令会发现压缩文件f2.txt.gz。

要想避免收到上面所说的出错提示信息。

我们可以使用命令:

gzip  < f1.txt > f2.txt.gz

[purpleendurer @ bash ~ ] ls
Code  d1  f1.txt  f2.txt
[purpleendurer @ bash ~ ] gzip  < f1.txt > f2.txt.gz
[purpleendurer @ bash ~ ] ls
Code  d1  f1.txt  f2.txt  f2.txt.gz
[purpleendurer @ bash ~ ] 

2.3 压缩多个文件

压缩当前目录下的文件f1.txt f2.txt,命令为:

gzip f1.txt f2.txt

[purpleendurer @ bash ~ ] ls
Code  d1  f1.txt  f2.txt  f2.txt.gz
[purpleendurer @ bash ~ ] gzip f1.txt f2.txt
gzip: f2.txt.gz already exists; do you wish to overwrite (y or n)? y
[purpleendurer @ bash ~ ] ls
Code  d1  f1.txt.gz  f2.txt.gz
[purpleendurer @ bash ~ ] 

在执行压缩命令的过程中,由于当前目录下已经存在文件f2.txt.gz,所以会提示是否覆盖该文件。

2.4 递归压缩目录树下的文件

为了实现递归压缩,我们要指定 -r 选项。

为了演示效果,我们在目录d1下再创建目录d2,在目录d2下创建文件fc.txt和fd.txt

[purpleendurer @ bash ~ ] mkdir d1/d2
[purpleendurer @ bash ~ ] echo "d2fc" > d1/d2/fc.txt
[purpleendurer @ bash ~ ] echo "d2fd" > d1/d2/fd.txt
[purpleendurer @ bash ~ ] ls -R
.:
Code  d1  f1.txt  f2.txt./Code:./d1:
d2  fa.txt  fb.txt./d1/d2:
fc.txt  fd.txt
[purpleendurer @ bash ~ ] 

然后我们将目录d1及子目录下的文件进行压缩

[purpleendurer @ bash ~ ] ls -R
.:
Code  d1  f1.txt  f2.txt./Code:./d1:
d2  fa.txt  fb.txt./d1/d2:
fc.txt  fd.txt
[purpleendurer @ bash ~ ] gzip -rv d1
d1/d2/fd.txt:   -40.0% -- replaced with d1/d2/fd.txt.gz
d1/d2/fc.txt:   -40.0% -- replaced with d1/d2/fc.txt.gz
d1/fb.txt:      -40.0% -- replaced with d1/fb.txt.gz
d1/fa.txt:      -40.0% -- replaced with d1/fa.txt.gz
[purpleendurer @ bash ~ ] ls -R
.:
Code  d1  f1.txt  f2.txt./Code:./d1:
d2  fa.txt.gz  fb.txt.gz./d1/d2:
fc.txt.gz  fd.txt.gz
[purpleendurer @ bash ~ ] 

为了更好地看到命令执行的过程和效果,我们指定了-v选项。

2.4 指定压缩速度

我们可以为gzip指定一个压缩速度,其速度范围值为1——9。

1 是最快的压缩,压缩率最低

9 是最慢的压缩,压缩率最高

默认是 6

2.4.1 汉字

我们先拿汉字试一下。

[purpleendurer @ bash ~ ] echo "LZ77 的基本原理:LZ77 以经常出现的字母组合(或较长的字符串)构建字典中的数据项,并且使用较短的数字(或符号)编码来代替比较复杂的数据 项。数据压缩时,将从待压缩数据中读入的源数据与字典中的数据项进行匹配,从中检索出相应的代码并输出。从而实现数据的压缩。" > f3.txt
[purpleendurer @ bash ~ ] gzip -1 -cv < f3.txt > f3-1.gz29.6%
[purpleendurer @ bash ~ ] gzip -4 -cv < f3.txt > f3-4.gz29.6%
[purpleendurer @ bash ~ ] gzip -9 -cv < f3.txt > f3-9.gz29.6%
[purpleendurer @ bash ~ ] gzip -cv < f3.txt > f3-9.gz29.6%
[purpleendurer @ bash ~ ] 

 

我们先把一段汉字存放在文件 f3.txt中,然后分别指定压缩速度 1、4、9和默认(6)来进行压缩。

从命令执行信息来看,压缩率没有差别。 

2.4.2 英文

我们再用常用英文单词试一下:

[purpleendurer @ bash ~ ] echo "I, you, he, she, it, we, they,be, have, do, go, make, see, take, get, give,person, time, day, year, way, man, woman, child, government, company,good, bad, big, little, new, old, happy, sad, beautiful, ugly,very, really, so, too, then, now, well, just, also, still,a, an, the,in, on, at, with, for, about, from, over, under, between,and, but, or, so, because, if, when, while, although, before, after,one, two, three, four, five, ten, hundred, thousand, million,hello, goodbye, please, thank you, sorry, excuse me, yes, no,I, you, he, she, it, we, they,be, have, do, go, make, see, take, get, give,person, time, day, year, way, man, woman, child, government, company,good, bad, big, little, new, old, happy, sad, beautiful, ugly,very, really, so, too, then, now, well, just, also, still,a, an, the,in, on, at, with, for, about, from, over, under, between,and, but, or, so, because, if, when, while, although, before, after,one, two, three, four, five, ten, hundred, thousand, million,hello, goodbye, please, thank you, sorry, excuse me, yes, no" > f4.txt
[purpleendurer @ bash ~ ] gzip -1 -cv < f4.txt > f4-1.gz70.7%
[purpleendurer @ bash ~ ] gzip -4 -cv < f4.txt > f4-4.gz71.0%
[purpleendurer @ bash ~ ] gzip -9 -cv < f4.txt > f4-9.gz71.0%
[purpleendurer @ bash ~ ] gzip -cv < f4.txt > f4-9.gz71.0%
[purpleendurer @ bash ~ ] 

我们先把常用英文单词存放在文件 f4.txt中,然后分别指定压缩速度 1、4、9和默认(6)来进行压缩。

从4开始,压缩率没有变化。所以一般使用默认(6)就可以了。

 2.5 测试压缩文件的完整性

我们可以使用选项-t或 --test来测试压缩文件的完整性。

例如:测试文件f3.txt.gz的完整性

[purpleendurer @ bash ~ ] gzip -cv < f3.txt > f3.txt.gz29.6%
[purpleendurer @ bash ~ ] gzip -t f3.txt.gz
[purpleendurer @ bash ~ ] gzip -tv f3.txt.gz
f3.txt.gz:       OK
[purpleendurer @ bash ~ ] 

 

可以看到, 执行命令:gzip -t f3.txt.gz 没反馈信息。

执行命令 gzip -tv f3.txt.gz 才看到反馈信息:

f3.txt.gz:       OK

注意:为了看到测试结果,建议同时指定-v选项。

2.6 查看压缩文件的详细信息

我们可以指定 -l 选项可以查看 .gz 文件的详细信息。

例如,查看f3.txt.gz的详细信息

[purpleendurer @ bash ~ ] gzip -l f3.txt.gzcompressed        uncompressed  ratio uncompressed_name279                 371  29.6% f3.txt
[purpleendurer @ bash ~ ] 

2.7 解压文件

我们可以使用选项 -d 或--decompress 来对压缩文件进行 解压缩。

例如,对压缩文件 f3.txt.gz 进行 解压缩

[purpleendurer @ bash ~ ] ls
Code  f3-1.gz  f3-4.gz  f3-9.gz  f3.txt
[purpleendurer @ bash ~ ] gzip -c < f3.txt >  f3.txt.gz
[purpleendurer @ bash ~ ] ls
Code  f3-1.gz  f3-4.gz  f3-9.gz  f3.txt  f3.txt.gz
[purpleendurer @ bash ~ ] gzip -dv f3.txt.gz
gzip: f3.txt already exists; do you wish to overwrite (y or n)? nnot overwritten
[purpleendurer @ bash ~ ] gzip -dfv f3.txt.gz
f3.txt.gz:       29.6% -- replaced with f3.txt
[purpleendurer @ bash ~ ] ls
Code  f3-1.gz  f3-4.gz  f3-9.gz  f3.txt
[purpleendurer @ bash ~ ] 

 

我们执行命令gzip -dv f3.txt.gz时,由于当前目录中存在文件f3.txt,会要求我们确定是否覆盖原有文件:

gzip: f3.txt already exists; do you wish to overwrite (y or n)? 

我们输入n后,反馈信息:

        not overwritten

没有覆盖原有文件。

如果我们不想接收和处理是否覆盖原有文件的信息,我们可以使用 -f选项强制覆盖原有文件。

所以我们执行命令 gzip -dfv f3.txt.gz 时 会直接覆盖原有文件f3.txt:

f3.txt.gz:       29.6% -- replaced with f3.txt 

2.8 查看版本信息

 我们可以使用-V选项查看当前使用的gzip版本信息。

2.8.1 测试用的bash中的gzip版本信息

[purpleendurer @ bash ~ ] gzip -V
gzip 1.5
Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.Written by Jean-loup Gailly.
[purpleendurer @ bash ~ ] 

 

2.8.2 银河麒麟(kylin)系统中的gzip版本信息

[purpleendurer @ kylin ~] gzip -v
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h
[purpleendurer @ kylin ~] gzip -V
gzip 1.6
Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.Written by Jean-loup Gailly.
[purpleendurer @ kylin ~] 

 

看来gzip的1.5版本不支持-k选项,而1.6版本支持-k选项。

2.9 查看软件许可证信息

我们可以使用-L 或 --license 选项 查看软件许可证信息。

2.9.1 测试用的bash中的gzip软件许可证信息

[purpleendurer @ bash ~ ] gzip -L
gzip 1.5
Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
[purpleendurer @ bash ~ ] 

显示的信息跟版本信息相似。

如果我们同时查看gzip版本和软件许可证信息会如何显示呢?

[purpleendurer @ bash ~ ] gzip -VL
gzip 1.5
Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.Written by Jean-loup Gailly.
[purpleendurer @ bash ~ ] 

 

显示的是软件许可证信息。

2.9.2 银河麒麟(kylin)系统中的gzipgzip软件许可证信息

[purpleendurer @ kylin ~] gzip -L
gzip 1.6
Copyright (C) 2007, 2010, 2011 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.
[purpleendurer @ kylin ~] 

3  LZ77编码

gzip 使用 LZ77  编码来压缩和解压文件。

LZ 编码由以色列研究者 Jacob Ziv 和 Abraham Lempel 提出,是无损压缩的核心思想。LZ 是一个系列的算法,而其中最基本的就是两人在 1977年所发表的论文《A Universal Algorithm for Sequential Compression》 中提出的 LZ77 算法。

LZ77的核心思想:利用数据的重复结构信息来进行数据压缩。

而Huffman等基于统计的数据压缩编码需要先对数据进行字符频率统计,然后进行压缩。

LZ77 的基本原理:LZ77 以经常出现的字母组合(或较长的字符串)构建字典中的数据项,并且使用较短的数字(或符号)编码来代替比较复杂的数据项。数据压缩时,将从待压缩数据中读入的源数据与字典中的数据项进行匹配,从中检索出相应的代码并输出。从而实现数据的压缩。

LZ77 编码是一种基于字典及滑动窗口的无损压缩技术,广泛应用于通信传输。

相关文章:

Linux shell编程学习笔记80:gzip命令——让文件瘦身

0 引言 在 Linux shell编程学习笔记76&#xff1a;tar命令——快照 & 备份&#xff08;上&#xff09;-CSDN博客 Linux shell编程学习笔记77&#xff1a;tar命令——快照 & 备份&#xff08;下&#xff09;_linux 系统快照-CSDN博客 Linux shell编程学习笔记78&am…...

【字幕】恋上数据结构与算法之01为什么要学习数据结构与算法

视频地址&#xff1a;请查看01为什么要学习数据结构与算法_哔哩哔哩_bilibili 同志们好&#xff0c;我是小码哥的mj李明杰。非常欢迎大家来学习链上数据结构与算法&#xff0c;从今天开始呢就由我来带大家一起来学习和掌握这个数据结构与算法啊。在正式学习之前我们先来看一下…...

120页ppt丨集团公司战略规划内容、方法、步骤及战略规划案例研究

响应会员需求&#xff0c;晓零分享一份经典资料《120页ppt集团公司战略规划内容、方法、步骤及战略规划案例研究》&#xff0c;欢迎进入星球下载学习。 以下是对企业战略规划三个阶段八个步骤的详细解析&#xff1a; 一、阶段一&#xff1a;内外分析 项目启动和前期准备&…...

滚雪球学SpringCloud[2.3]:服务发现与负载均衡详解

全文目录&#xff1a; 前言1. Ribbon的使用与配置1.1 Ribbon 概述Ribbon 的核心功能&#xff1a; 1.2 Ribbon 的基本使用1.2.1 引入 Ribbon 依赖1.2.2 配置 RestTemplate 与 Ribbon1.2.3 示例&#xff1a;通过 Ribbon 调用服务 1.3 Ribbon 的配置选项 2. Ribbon的负载均衡策略2…...

商务英语口语之聚会宴饮常用口语柯桥培训到蓝天广场

吃饭一定要掌握的英语口语 邀请他人共进餐&#xff1a; Would you like to join me for dinner? 你愿意和我一起吃饭吗&#xff1f; Lets grab a bite to eat together. 我们一起去吃点东西吧。 How about having lunch with me? 和我一起吃午饭怎么样&#xff1f; 询问…...

【C#】VS插件

翻译 目前推荐较多的 可以单词发言&#xff0c;目前还在开发阶段 TranslateIntoChinese - Visual Studio Marketplace 下载量最高的(推荐) Visual-Studio-Translator - Visual Studio Marketplace 支持翻译的版本较多&#xff0c;在 Visual Studio 代码编辑器中通过 Googl…...

嵌入式C语言自我修养:C语言的面向对象编程思想

⭐关联知识点&#xff1a;C和C的区别 代码复用与分层思想 什么是代码复用呢&#xff1f; &#xff08;1&#xff09;函数级代码复用&#xff1a;定义一个函数实现某个功能&#xff0c;所有的程序都可以调用这个函数&#xff0c;不用自己再单独实现一遍&#xff0c;函数级的代…...

行车记录仪格式化了怎么恢复?专业恢复方法分享

行车记录仪作为现代驾驶的必备设备&#xff0c;它忠实记录着行车过程中的点点滴滴&#xff0c;是保障行车安全、处理交通事故的重要依据。然而&#xff0c;有时由于操作失误或其他原因&#xff0c;我们可能会不小心将行车记录仪进行格式化&#xff0c;导致宝贵的录像数据丢失。…...

C++中extern ”c“的理解

c中extern “C“的作用及理解_extern "c-CSDN博客...

红黑树的删除

文章目录 前言一.删除的节点左子树右子树都有二.删除的节点只有左/右子树删除调整操作 三.删除的节点没有孩子1.删除的节点为红色2.删除的节点为黑色1).兄弟节点为黑色(1).兄弟节点至少有一个红色的孩子节点LL型RR型RL型LR型 (2).兄弟节点没有孩子或所有孩子为黑色 2).兄弟节点…...

Vue3+setup实现父子组件单表增删改查写法模板

父组件写法 <el-card><!-- el-card 头部插槽 显示列表名和新增按钮 --><template #header><div class"table-header-container"><i class"fas fa-th" />角色列表&#xff08;100&#xff09;<span style"flex-grow…...

jmeter 录制APP脚本

一、手机 1、修改网络 代理选择手动→填写服务器主机名&#xff08;电脑IP&#xff0c;如&#xff1a;192.1xx.x.xx&#xff09;→服务器端口&#xff08;任意未被占用端口&#xff0c;如&#xff1a;8888&#xff09; 2、安装证书 手机浏览器访问服务器主机名:服务器端口&a…...

C++类与对象深度解析(一):从抽象到实践的全面入门指南

文章目录 C 类与对象——详细入门指南前言1. 类的定义1.1 类定义的基本格式示例代码解释 1.2 访问限定符示例代码解释 1.3 类域示例代码解释 1.4 成员命名规范常见的命名约定&#xff1a;示例&#xff1a;拓展&#xff1a; 1.5 class与struct的默认访问权限示例&#xff1a; 2.…...

docker拉取 jdk 8

docker pull openjdk:8docker run -d -it --name java-8 openjdk:8docker run -d -it --name java-8 openjdk:8 –name java-8 容器名&#xff0c;自定义的 openjdk:8 镜像名&#xff1a;标签名 &#xff0c; 使用 docker images 查看 2、查看已运行的容器实例&#xff1a; doc…...

机器学习VS深度学习

机器学习&#xff08;Machine Learning, ML&#xff09;和深度学习&#xff08;Deep Learning, DL&#xff09;是人工智能&#xff08;AI&#xff09;的两个子领域&#xff0c;它们有许多相似之处&#xff0c;但在技术实现和应用范围上也有显著区别。下面从几个方面对两者进行区…...

基于vue框架的宠物交流平台1n2n3(程序+源码+数据库+调试部署+开发环境)系统界面在最后面。

系统程序文件列表 项目功能&#xff1a;会员,宠物信息,宠物类型,团队信息,申请领养,团队申请,领养宠物 开题报告内容 基于Vue框架的宠物交流平台开题报告 一、项目背景 随着现代生活节奏的加快与人们情感需求的日益增长&#xff0c;宠物已成为众多家庭不可或缺的重要成员。…...

Rust 所有权 借用与引用

文章目录 发现宝藏1. 所有权&#xff08;Ownership&#xff09;2. 引用&#xff08;References&#xff09;2.1 不可变引用2.2 可变引用2.3 引用的规则 3. 悬垂引用&#xff08;Dangling References&#xff09;4. 借用&#xff08;Borrowing&#xff09;结论 发现宝藏 前些天…...

构建智能电商新生态:深度解析京东商品详情API的力量

在当今数字化浪潮中&#xff0c;智能电商系统已成为推动零售业转型升级的重要引擎。作为电商行业的领军者之一&#xff0c;京东凭借其庞大的商品数据库和先进的技术架构&#xff0c;为开发者与商家提供了丰富的API接口&#xff0c;其中商品详情API无疑是构建智能电商系统的关键…...

Golang | Leetcode Golang题解之第398题随机数索引

题目&#xff1a; 题解&#xff1a; type Solution []intfunc Constructor(nums []int) Solution {return nums }func (nums Solution) Pick(target int) (ans int) {cnt : 0for i, num : range nums {if num target {cnt // 第 cnt 次遇到 targetif rand.Intn(cnt) 0 {ans …...

使用注意力机制可以让你的模型更加灵活,但是需要额外的计算资源。rnn lstm bilstm attension

确实&#xff0c;使用注意力机制可以使模型更加灵活&#xff0c;但也确实需要额外的计算资源。注意力机制允许模型在处理序列数据时&#xff0c;能够动态地关注不同位置的重要性&#xff0c;从而更好地捕捉长依赖关系。下面是一个简单的注意力机制实现示例&#xff0c;可以帮助…...

19c补丁后oracle属主变化,导致不能识别磁盘组

补丁后服务器重启&#xff0c;数据库再次无法启动 ORA01017: invalid username/password; logon denied Oracle 19c 在打上 19.23 或以上补丁版本后&#xff0c;存在与用户组权限相关的问题。具体表现为&#xff0c;Oracle 实例的运行用户&#xff08;oracle&#xff09;和集…...

《Playwright:微软的自动化测试工具详解》

Playwright 简介:声明内容来自网络&#xff0c;将内容拼接整理出来的文档 Playwright 是微软开发的自动化测试工具&#xff0c;支持 Chrome、Firefox、Safari 等主流浏览器&#xff0c;提供多语言 API&#xff08;Python、JavaScript、Java、.NET&#xff09;。它的特点包括&a…...

CRMEB 框架中 PHP 上传扩展开发:涵盖本地上传及阿里云 OSS、腾讯云 COS、七牛云

目前已有本地上传、阿里云OSS上传、腾讯云COS上传、七牛云上传扩展 扩展入口文件 文件目录 crmeb\services\upload\Upload.php namespace crmeb\services\upload;use crmeb\basic\BaseManager; use think\facade\Config;/*** Class Upload* package crmeb\services\upload* …...

学校时钟系统,标准考场时钟系统,AI亮相2025高考,赛思时钟系统为教育公平筑起“精准防线”

2025年#高考 将在近日拉开帷幕&#xff0c;#AI 监考一度冲上热搜。当AI深度融入高考&#xff0c;#时间同步 不再是辅助功能&#xff0c;而是决定AI监考系统成败的“生命线”。 AI亮相2025高考&#xff0c;40种异常行为0.5秒精准识别 2025年高考即将拉开帷幕&#xff0c;江西、…...

微软PowerBI考试 PL300-在 Power BI 中清理、转换和加载数据

微软PowerBI考试 PL300-在 Power BI 中清理、转换和加载数据 Power Query 具有大量专门帮助您清理和准备数据以供分析的功能。 您将了解如何简化复杂模型、更改数据类型、重命名对象和透视数据。 您还将了解如何分析列&#xff0c;以便知晓哪些列包含有价值的数据&#xff0c;…...

回溯算法学习

一、电话号码的字母组合 import java.util.ArrayList; import java.util.List;import javax.management.loading.PrivateClassLoader;public class letterCombinations {private static final String[] KEYPAD {"", //0"", //1"abc", //2"…...

人工智能(大型语言模型 LLMs)对不同学科的影响以及由此产生的新学习方式

今天是关于AI如何在教学中增强学生的学习体验&#xff0c;我把重要信息标红了。人文学科的价值被低估了 ⬇️ 转型与必要性 人工智能正在深刻地改变教育&#xff0c;这并非炒作&#xff0c;而是已经发生的巨大变革。教育机构和教育者不能忽视它&#xff0c;试图简单地禁止学生使…...

Windows安装Miniconda

一、下载 https://www.anaconda.com/download/success 二、安装 三、配置镜像源 Anaconda/Miniconda pip 配置清华镜像源_anaconda配置清华源-CSDN博客 四、常用操作命令 Anaconda/Miniconda 基本操作命令_miniconda创建环境命令-CSDN博客...

深度学习之模型压缩三驾马车:模型剪枝、模型量化、知识蒸馏

一、引言 在深度学习中&#xff0c;我们训练出的神经网络往往非常庞大&#xff08;比如像 ResNet、YOLOv8、Vision Transformer&#xff09;&#xff0c;虽然精度很高&#xff0c;但“太重”了&#xff0c;运行起来很慢&#xff0c;占用内存大&#xff0c;不适合部署到手机、摄…...

论文阅读:LLM4Drive: A Survey of Large Language Models for Autonomous Driving

地址&#xff1a;LLM4Drive: A Survey of Large Language Models for Autonomous Driving 摘要翻译 自动驾驶技术作为推动交通和城市出行变革的催化剂&#xff0c;正从基于规则的系统向数据驱动策略转变。传统的模块化系统受限于级联模块间的累积误差和缺乏灵活性的预设规则。…...