<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>编程 归档 - 帝讯博客</title>
	<atom:link href="https://www.dixunblog.cn/collection/%e7%bc%96%e7%a8%8b/feed" rel="self" type="application/rss+xml" />
	<link>https://www.dixunblog.cn/collection/编程</link>
	<description>致力于打造专业的互联网资讯平台</description>
	<lastBuildDate>Mon, 27 Apr 2026 03:19:55 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://cdn.hyclive.cn/dixunblog/2025/12/cropped-ico-32x32.png</url>
	<title>编程 归档 - 帝讯博客</title>
	<link>https://www.dixunblog.cn/collection/编程</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Linux 基础知识完全指南：从零开始理解 Linux 系统</title>
		<link>https://www.dixunblog.cn/1748.html</link>
					<comments>https://www.dixunblog.cn/1748.html#respond</comments>
		
		<dc:creator><![CDATA[老大]]></dc:creator>
		<pubDate>Mon, 27 Apr 2026 03:19:42 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux 教程]]></category>
		<category><![CDATA[Linux系统]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/?p=1748</guid>

					<description><![CDATA[<p>写在前面 很多人第一次听说 Linux，是因为想搭建网站、学习编程，或者工作上要用到服务器。但打开终端看到黑底白字的界面，就开始发懵：这玩意儿和 Windows 完全不一样啊。 其实 Linux 不难理解。它就是个操作系统，和 Windows、macOS 一样，只是设计理念不同。这篇文章把 Linux 的基础知识一次性讲清楚：什么是 Linux、为什么用它、文件系统怎么组织、权限怎么管理、软件怎么安装……看完这篇，你对 Linux 就有个整体认知了。 建议先收藏，以后遇到问题可以对照查阅。 一、什么是 Linux？</p>
<p><a href="https://www.dixunblog.cn/1748.html">Linux 基础知识完全指南：从零开始理解 Linux 系统</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<h2>写在前面</h2>
<p>很多人第一次听说 Linux，是因为想搭建网站、学习编程，或者工作上要用到服务器。但打开终端看到黑底白字的界面，就开始发懵：这玩意儿和 Windows 完全不一样啊。</p>
<p>其实 Linux 不难理解。它就是个操作系统，和 Windows、macOS 一样，只是设计理念不同。这篇文章把 Linux 的基础知识一次性讲清楚：什么是 Linux、为什么用它、文件系统怎么组织、权限怎么管理、软件怎么安装……看完这篇，你对 Linux 就有个整体认知了。</p>
<p>建议先收藏，以后遇到问题可以对照查阅。</p>
<hr />
<h2>一、什么是 Linux？</h2>
<p><img fetchpriority="high" decoding="async" class="size-full wp-image-1749 aligncenter" src="http://cdn.hyclive.cn/dixunblog/2026/04/v2-6a22da24bf48ea75bbbd9bc258851cce_720w.jpg" alt="" width="532" height="300" /></p>
<h3>1.1 Linux 的本质</h3>
<p>Linux 是一个操作系统内核，加上各种软件工具，构成了完整的操作系统。</p>
<p>打个比方：</p>
<ul>
<li><strong>内核</strong>：相当于汽车的发动机，负责驱动硬件、管理资源</li>
<li><strong>外壳（Shell）</strong>：相当于方向盘和操控面板，让用户能操作系统</li>
<li><strong>应用程序</strong>：相当于车上的导航、音响，提供各种功能</li>
</ul>
<p>Linux 内核最早由 Linus Torvalds 在 1991 年开发，后来开源，全世界开发者都能贡献代码。现在 Linux 内核已经非常成熟，驱动了从手机到服务器到超级计算机的各种设备。</p>
<h3>1.2 Linux 和 Windows 的区别</h3>
<table>
<thead>
<tr>
<th>对比项</th>
<th>Windows</th>
<th>Linux</th>
</tr>
</thead>
<tbody>
<tr>
<td>设计理念</td>
<td>商业产品，用户友好</td>
<td>开源免费，技术导向</td>
</tr>
<tr>
<td>操作方式</td>
<td>图形界面为主</td>
<td>命令行为主（也有图形界面）</td>
</tr>
<tr>
<td>权限管理</td>
<td>管理员账户</td>
<td>root 和普通用户分离</td>
</tr>
<tr>
<td>软件安装</td>
<td>下载安装包或商店</td>
<td>包管理器（yum/apt等）</td>
</tr>
<tr>
<td>文件系统</td>
<td>C盘D盘分区</td>
<td>单一树状结构</td>
</tr>
<tr>
<td>配置方式</td>
<td>控制面板</td>
<td>配置文件</td>
</tr>
<tr>
<td>适用场景</td>
<td>个人电脑、办公</td>
<td>服务器、开发、嵌入式</td>
</tr>
</tbody>
</table>
<p>最大的区别：Windows 鼠标点几下就行，Linux 很多操作要敲命令。但命令的优势是效率高、可自动化、能远程操作。</p>
<h3>1.3 Linux 的应用场景</h3>
<p><strong>服务器领域：</strong></p>
<ul>
<li>网站服务器：全球 90% 以上的网站服务器运行 Linux</li>
<li>云计算：阿里云、腾讯云、AWS 的服务器都是 Linux</li>
<li>数据库服务器：MySQL、Redis 通常部署在 Linux</li>
</ul>
<p><strong>开发领域：</strong></p>
<ul>
<li>编程环境：Python、Go、Java 开发者偏好 Linux</li>
<li>容器技术：Docker、Kubernetes 基于 Linux</li>
<li>DevOps：自动化部署、持续集成</li>
</ul>
<p><strong>嵌入式设备：</strong></p>
<ul>
<li>手机：Android 基于 Linux 内核</li>
<li>路由器：家用路由器的系统</li>
<li>智能设备：智能家居、车载系统</li>
</ul>
<p><strong>个人使用：</strong></p>
<ul>
<li>开发者日常开发</li>
<li>系统运维工作</li>
<li>学习计算机原理</li>
</ul>
<p>简单说：服务器上 Linux 是主流，个人电脑上 Windows 是主流。</p>
<hr />
<h2>二、Linux 发行版：选择适合自己的版本</h2>
<h3>2.1 什么是发行版？</h3>
<p>Linux 内核只是核心部分，要变成能用的操作系统，需要加上：</p>
<ul>
<li>图形界面（可选）</li>
<li>常用软件（文本编辑器、浏览器等）</li>
<li>包管理器（安装软件的工具）</li>
<li>系统配置工具</li>
</ul>
<p>不同的组织把这些组合起来，打包成不同的&#8221;发行版&#8221;。</p>
<p>打个比方：内核是面粉，发行版是面条、面包、馒头——原料相同，形态不同。</p>
<h3>2.2 主要发行版介绍</h3>
<p><strong>（1）Ubuntu</strong></p>
<p>最适合新手入门的发行版。</p>
<p>特点：</p>
<ul>
<li>安装简单，图形界面友好</li>
<li>软件丰富，社区活跃</li>
<li>定期发布新版本（每6个月）</li>
<li>有 LTS 版本（长期支持，5年更新）</li>
</ul>
<p>适用人群：新手、个人用户、开发者</p>
<p>下载：ubuntu.com</p>
<hr />
<p><strong>（2）CentOS / Rocky Linux</strong></p>
<p>服务器最常用的发行版。</p>
<p>特点：</p>
<ul>
<li>稳定可靠，适合生产环境</li>
<li>软件版本保守（追求稳定，不求最新）</li>
<li>免费（CentOS 7 及之前）</li>
<li>CentOS 8 停止维护后，推荐用 Rocky Linux 或 AlmaLinux</li>
</ul>
<p>适用人群：运维工程师、服务器部署</p>
<p>注意：CentOS 7 在 2024 年 6 月停止维护，新项目建议用 Rocky Linux。</p>
<hr />
<p><strong>（3）Debian</strong></p>
<p>老牌发行版，Ubuntu 的上游。</p>
<p>特点：</p>
<ul>
<li>极其稳定，软件测试严格</li>
<li>完全社区驱动，非商业</li>
<li>更新周期较长</li>
</ul>
<p>适用人群：追求稳定的服务器用户、技术人员</p>
<hr />
<p><strong>（4）Fedora</strong></p>
<p>Red Hat 的社区版，新技术试验场。</p>
<p>特点：</p>
<ul>
<li>软件版本较新</li>
<li>半年发布一个版本</li>
<li>Red Hat Enterprise Linux（RHEL）的上游</li>
</ul>
<p>适用人群：想体验新技术的开发者</p>
<hr />
<p><strong>（5）Arch Linux</strong></p>
<p>极简主义发行版，高度自定义。</p>
<p>特点：</p>
<ul>
<li>滚动更新（没有版本概念，始终最新）</li>
<li>安装复杂（从零构建）</li>
<li>文档完善（Arch Wiki）</li>
</ul>
<p>适用人群：Linux 高手、追求极致自定义</p>
<hr />
<p><strong>（6）其他常见发行版</strong></p>
<table>
<thead>
<tr>
<th>发行版</th>
<th>特点</th>
<th>适用人群</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mint</td>
<td>基于 Ubuntu，界面类似 Windows</td>
<td>从 Windows 转过来的用户</td>
</tr>
<tr>
<td>openSUSE</td>
<td>德国发行版，企业级稳定</td>
<td>企业用户</td>
</tr>
<tr>
<td>Kali</td>
<td>安全工具预装</td>
<td>安全测试、渗透测试</td>
</tr>
<tr>
<td>Gentoo</td>
<td>从源码编译安装</td>
<td>高级玩家</td>
</tr>
<tr>
<td>Alpine</td>
<td>极小体积（5MB）</td>
<td>容器、嵌入式</td>
</tr>
</tbody>
</table>
<h3>2.3 发行版选择建议</h3>
<p><strong>新手入门：</strong> Ubuntu 或 Mint<br />
<strong>服务器部署：</strong> Rocky Linux / AlmaLinux（替代 CentOS）<br />
<strong>开发环境：</strong> Ubuntu 或 Fedora<br />
<strong>运维学习：</strong> Rocky Linux（和 CentOS 7 用法一样）</p>
<hr />
<h2>三、Linux 文件系统：目录结构详解</h2>
<h3>3.1 单一树状结构</h3>
<p>Linux 没有 Windows 的 C盘D盘概念，所有文件都在一个树状结构里，根目录是 <code>/</code>。</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">/                     根目录
├── bin               可执行命令（所有用户都能用）
├── boot              启动相关文件
├── dev               设备文件（硬件设备在这里）
├── etc               系统配置文件
├── home              用户主目录
│   ├── user1         用户 user1 的主目录
│   └── user2         用户 user2 的主目录
├── lib               库文件
├── media             可移动设备挂载点（U盘等）
├── mnt               临时挂载点
├── opt               可选软件包安装位置
├── proc              进程信息（虚拟文件系统）
├── root              root 用户的主目录
├── run               运行时数据
├── sbin              系统管理命令（只有 root 能用）
├── srv               服务数据
├── sys               系统信息（虚拟文件系统）
├── tmp               临时文件
├── usr               用户程序和数据
│   ├── bin           用户安装的命令
│   ├── lib           用户安装的库
│   ├── local         本地安装的软件
│   └── share         共享数据
└── var               可变数据（日志、缓存等）
    ├── log           系统日志
    ├── cache         缓存数据
    └── lib           应用程序数据</code></pre>
<h3>3.2 重要目录详解</h3>
<p><strong><code>/</code> 根目录</strong></p>
<p>所有文件和目录的起点。不要在根目录放文件，这是系统区域。</p>
<hr />
<p><strong><code>/bin</code> 和 <code>/sbin</code></strong></p>
<p>存放系统命令：</p>
<ul>
<li><code>/bin</code>：所有用户都能执行的命令（ls、cp、cat 等）</li>
<li><code>/sbin</code>：只有 root 能执行的管理命令（reboot、fdisk 等）</li>
</ul>
<p>在 CentOS 7+ 中，这些目录是 <code>/usr/bin</code> 和 <code>/usr/sbin</code> 的软链接。</p>
<hr />
<p><strong><code>/etc</code> 配置文件</strong></p>
<p>系统大部分配置文件都在这里。</p>
<p>重要文件：</p>
<ul>
<li><code>/etc/passwd</code>：用户信息</li>
<li><code>/etc/shadow</code>：用户密码（加密存储）</li>
<li><code>/etc/group</code>：组信息</li>
<li><code>/etc/fstab</code>：磁盘挂载配置</li>
<li><code>/etc/hosts</code>：本地域名解析</li>
<li><code>/etc/resolv.conf</code>：DNS 配置</li>
<li><code>/etc/sysconfig/network-scripts/</code>：网络配置（CentOS）</li>
<li><code>/etc/ssh/sshd_config</code>：SSH 服务配置</li>
<li><code>/etc/nginx/nginx.conf</code>：Nginx 配置（如果安装了）</li>
<li><code>/etc/apt/sources.list</code>：软件源配置（Ubuntu）</li>
<li><code>/etc/yum.repos.d/</code>：软件源配置（CentOS）</li>
</ul>
<p>修改配置文件通常需要 root 权限。</p>
<hr />
<p><strong><code>/home</code> 用户主目录</strong></p>
<p>每个用户有一个专属目录，存放个人文件。</p>
<p>路径格式：<code>/home/用户名</code></p>
<p>比如用户 tom 的主目录是 <code>/home/tom</code>。</p>
<p>用户主目录可以简写为 <code>~</code>，比如：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">cd ~              # 进入主目录
ls ~/Documents    # 查看主目录下的 Documents</code></pre>
<hr />
<p><strong><code>/root</code> root 用户主目录</strong></p>
<p>root 用户的主目录不在 <code>/home</code>，而是独立的 <code>/root</code>。</p>
<hr />
<p><strong><code>/var</code> 可变数据</strong></p>
<p>存放会经常变化的数据。</p>
<p>重要子目录：</p>
<ul>
<li><code>/var/log</code>：日志文件（查看系统运行情况）</li>
<li><code>/var/cache</code>：缓存数据</li>
<li><code>/var/lib</code>：应用程序数据（数据库文件等）</li>
<li><code>/var/spool</code>：队列数据（邮件队列等）</li>
<li><code>/var/tmp</code>：临时文件（比 <code>/tmp</code> 保留时间更长）</li>
</ul>
<hr />
<p><strong><code>/usr</code> 用户程序</strong></p>
<p>存放用户安装的软件和文档。</p>
<ul>
<li><code>/usr/bin</code>：用户安装的命令</li>
<li><code>/usr/lib</code>：库文件</li>
<li><code>/usr/local</code>：手动安装的软件（非包管理器安装）</li>
<li><code>/usr/share</code>：共享数据（文档、图标等）</li>
</ul>
<hr />
<p><strong><code>/tmp</code> 临时文件</strong></p>
<p>存放临时文件，重启后通常会清空。所有用户都能读写。</p>
<hr />
<p><strong><code>/proc</code> 进程信息</strong></p>
<p>这是一个虚拟文件系统，存放内核和进程信息。文件不是真实存在，而是内存数据的映射。</p>
<p>查看内存信息：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">cat /proc/meminfo</code></pre>
<p>查看 CPU 信息：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">cat /proc/cpuinfo</code></pre>
<p>查看某个进程的信息：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ls /proc/1234/     # 1234 是进程 PID</code></pre>
<hr />
<p><strong><code>/dev</code> 设备文件</strong></p>
<p>Linux 把硬件设备当作文件来管理，设备文件都在 <code>/dev</code>。</p>
<p>常见设备文件：</p>
<ul>
<li><code>/dev/sda</code>：第一块硬盘</li>
<li><code>/dev/sda1</code>：第一块硬盘的第一个分区</li>
<li><code>/dev/null</code>：黑洞，写入的东西都消失</li>
<li><code>/dev/zero</code>：无限输出 0</li>
<li><code>/dev/tty</code>：终端设备</li>
<li><code>/dev/urandom</code>：随机数生成器</li>
</ul>
<hr />
<p><strong><code>/boot</code> 启动文件</strong></p>
<p>存放系统启动需要的文件：</p>
<ul>
<li>内核文件（vmlinuz）</li>
<li>启动配置（grub）</li>
</ul>
<p>不要随意修改这个目录，否则可能导致系统无法启动。</p>
<hr />
<p><strong><code>/opt</code> 可选软件</strong></p>
<p>一些第三方软件安装在这里，比如 Oracle 数据库。</p>
<hr />
<p><strong><code>/mnt</code> 和 <code>/media</code> 挂载点</strong></p>
<p>挂载外部设备的目录：</p>
<ul>
<li><code>/mnt</code>：手动挂载的设备</li>
<li><code>/media</code>：自动挂载的设备（U盘、光盘）</li>
</ul>
<hr />
<h3>3.3 文件路径概念</h3>
<p><strong>绝对路径</strong></p>
<p>从根目录 <code>/</code> 开始的完整路径。</p>
<p>例子：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">/etc/passwd
/home/user/Documents/file.txt
/var/log/nginx/error.log</code></pre>
<p><strong>相对路径</strong></p>
<p>从当前目录开始的路径。</p>
<p>例子：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">Documents/file.txt      # 当前目录下的 Documents
../etc/passwd           # 上级目录下的 etc
./script.sh             # 当前目录下的 script.sh</code></pre>
<p><code>./</code> 表示当前目录，<code>../</code> 表示上级目录。</p>
<hr />
<h2>四、Linux 用户和权限管理</h2>
<h3>4.1 用户概念</h3>
<p>Linux 是多用户系统，可以同时有多个用户登录使用。</p>
<p><strong>用户类型：</strong></p>
<ol>
<li><strong>root 用户</strong>
<ul>
<li>超级管理员，拥有最高权限</li>
<li>能做任何操作（包括删系统）</li>
<li>UID 为 0</li>
</ul>
</li>
<li><strong>普通用户</strong>
<ul>
<li>权限受限，只能操作自己的文件</li>
<li>UID 从 1000 开始（CentOS 7+）</li>
<li>需要用 sudo 执行需要 root 权限的操作</li>
</ul>
</li>
<li><strong>系统用户</strong>
<ul>
<li>运行服务的用户（比如 nginx、mysql）</li>
<li>不能登录系统</li>
<li>UID 通常在 1-999</li>
</ul>
</li>
</ol>
<p><strong>用户信息文件：</strong></p>
<p><code>/etc/passwd</code> 存放用户基本信息：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">root:x:0:0:root:/root:/bin/bash
user:x:1000:1000::/home/user:/bin/bash</code></pre>
<p>格式：用户名:密码占位:UID:GID:描述:主目录:Shell</p>
<p>密码实际存放在 <code>/etc/shadow</code>，加密存储。</p>
<hr />
<h3>4.2 用户组概念</h3>
<p>用户组是一组用户的集合，方便批量管理权限。</p>
<p>每个用户至少属于一个组（主组），还可以加入多个附加组。</p>
<p><strong>组信息文件：</strong></p>
<p><code>/etc/group</code> 存放组信息：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">root:x:0:
wheel:x:10:user
user:x:1000:</code></pre>
<p>格式：组名:密码占位:GID:组成员列表</p>
<hr />
<h3>4.3 文件权限详解</h3>
<p>Linux 文件权限分三部分：用户、组、其他人。</p>
<p>每部分有三种权限：</p>
<ul>
<li><strong>r（读）</strong>：值 4，可以查看内容</li>
<li><strong>w（写）</strong>：值 2，可以修改内容</li>
<li><strong>x（执行）</strong>：值 1，可以执行（脚本、程序）</li>
</ul>
<p>权限用数字或字母表示：</p>
<table>
<thead>
<tr>
<th>权限组合</th>
<th>数字</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>rwx</td>
<td>7</td>
<td>读、写、执行</td>
</tr>
<tr>
<td>rw-</td>
<td>6</td>
<td>读、写</td>
</tr>
<tr>
<td>r-x</td>
<td>5</td>
<td>读、执行</td>
</tr>
<tr>
<td>r&#8211;</td>
<td>4</td>
<td>只读</td>
</tr>
<tr>
<td>-wx</td>
<td>3</td>
<td>写、执行</td>
</tr>
<tr>
<td>-w-</td>
<td>2</td>
<td>只写</td>
</tr>
<tr>
<td>&#8211;x</td>
<td>1</td>
<td>只执行</td>
</tr>
<tr>
<td>&#8212;</td>
<td>0</td>
<td>无权限</td>
</tr>
</tbody>
</table>
<p><strong>权限显示格式：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ls -l file.txt
# 输出：-rw-r--r-- 1 user group 1024 Jan 10 file.txt</code></pre>
<p>解析：</p>
<ul>
<li>第1位：文件类型（<code>-</code> 文件，<code>d</code> 目录，<code>l</code> 链接）</li>
<li>第2-4位：用户权限（rw- = 6）</li>
<li>第5-7位：组权限（r&#8211; = 4）</li>
<li>第8-10位：其他人权限（r&#8211; = 4）</li>
</ul>
<p>所以这个文件的权限是 644。</p>
<hr />
<h3>4.4 目录权限</h3>
<p>目录的权限含义和文件不同：</p>
<ul>
<li><strong>r（读）</strong>：可以查看目录内容（ls）</li>
<li><strong>w（写）</strong>：可以在目录里创建、删除文件</li>
<li><strong>x（执行）</strong>：可以进入目录（cd）</li>
</ul>
<p>要进入目录并查看内容，需要 rx 权限；要修改目录内容，需要 wx 权限。</p>
<hr />
<h3>4.5 特殊权限</h3>
<p>除了普通权限，Linux 还有三种特殊权限：</p>
<p><strong>SUID（4）</strong></p>
<p>设置在可执行文件上，执行时获得文件所有者的权限。</p>
<p>例子：<code>/usr/bin/passwd</code> 有 SUID，普通用户执行时暂时获得 root 权限修改密码。</p>
<p>显示：权限位变成 <code>rws</code></p>
<hr />
<p><strong>SGID（2）</strong></p>
<p>设置在目录上，目录里创建的文件自动继承目录的所属组。</p>
<p>显示：权限位变成 <code>rws</code></p>
<hr />
<p><strong>Sticky Bit（1）</strong></p>
<p>设置在目录上，只有文件所有者才能删除自己的文件。</p>
<p>例子：<code>/tmp</code> 有 Sticky Bit，用户不能删除别人的临时文件。</p>
<p>显示：权限位变成 <code>rwt</code></p>
<hr />
<h3>4.6 修改权限和所有权</h3>
<p><strong>chmod 修改权限：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">chmod 755 file.sh          # 用户全权限，其他人 rx
chmod 644 file.txt         # 用户 rw，其他人 r
chmod +x script.sh         # 给所有人加执行权限
chmod -R 755 folder        # 递归修改目录</code></pre>
<hr />
<p><strong>chown 修改所有者：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">chown user file.txt        # 改用户
chown user:group file.txt  # 改用户和组
chown -R user:group folder # 递归修改目录</code></pre>
<hr />
<p><strong>chgrp 修改所属组：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">chgrp group file.txt       # 改组</code></pre>
<hr />
<h3>4.7 sudo 权限管理</h3>
<p>普通用户需要执行 root 权限命令时，用 sudo。</p>
<p><strong>配置 sudo 权限：</strong></p>
<p>编辑 <code>/etc/sudoers</code>（用 visudo 命令，会检查语法）：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono "># 允许 user 执行所有命令
user ALL=(ALL) ALL

# 允许 wheel 组成员执行所有命令（CentOS 默认）
%wheel ALL=(ALL) ALL

# 只允许 user 执行特定命令
user ALL=(ALL) /usr/bin/reboot, /usr/bin/systemctl</code></pre>
<p><strong>使用 sudo：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">sudo command               # 以 root 执行命令
sudo -u user command       # 以指定用户执行
sudo -l                    # 查看可用 sudo 执行哪些命令</code></pre>
<hr />
<h2>五、Shell 和终端基础</h2>
<h3>5.1 什么是 Shell？</h3>
<p>Shell 是用户和内核之间的桥梁，负责解释用户输入的命令，传给内核执行。</p>
<p>常见 Shell：</p>
<ul>
<li><strong>bash</strong>：最常用的 Shell，几乎所有 Linux 默认使用</li>
<li><strong>zsh</strong>：功能更强，插件丰富（Oh My Zsh）</li>
<li><strong>sh</strong>：最基础的 Shell</li>
<li><strong>dash</strong>：轻量级 Shell，Ubuntu 用它作为 /bin/sh</li>
<li><strong>fish</strong>：友好的交互式 Shell</li>
</ul>
<p>查看当前 Shell：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">echo $SHELL
# 输出：/bin/bash</code></pre>
<p>查看可用 Shell：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">cat /etc/shells</code></pre>
<p>切换 Shell：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">chsh -s /bin/zsh           # 切换到 zsh</code></pre>
<hr />
<h3>5.2 终端和虚拟控制台</h3>
<p><strong>终端（Terminal）</strong></p>
<p>输入命令的界面，可以是：</p>
<ul>
<li>物理终端：以前的字符终端设备</li>
<li>软件终端：终端模拟软件（如 GNOME Terminal、iTerm2）</li>
<li>SSH 远程终端：通过 SSH 连接的终端</li>
</ul>
<p><strong>虚拟控制台</strong></p>
<p>Linux 有多个虚拟控制台（类似多个终端窗口），可以切换：</p>
<ul>
<li>按 Ctrl+Alt+F1~F6：切换到不同控制台</li>
<li>F1 通常是图形界面</li>
<li>F2~F6 是字符界面</li>
</ul>
<p>服务器没有图形界面时，用虚拟控制台登录。</p>
<hr />
<h3>5.3 Shell 基础操作</h3>
<p><strong>命令基本格式：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">命令 [选项] [参数]</code></pre>
<p>例子：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ls -l /home               # 命令 ls，选项 -l，参数 /home
cp -r folder1 folder2     # 命令 cp，选项 -r，参数 folder1 和 folder2</code></pre>
<p><strong>选项格式：</strong></p>
<ul>
<li>短选项：<code>-l</code>、<code>-a</code>、<code>-h</code>（单个字母）</li>
<li>长选项：<code>--help</code>、<code>--version</code>（完整单词）</li>
<li>组合短选项：<code>-lah</code> 等于 <code>-l -a -h</code></li>
</ul>
<hr />
<p><strong>常用快捷键：</strong></p>
<table>
<thead>
<tr>
<th>快捷键</th>
<th>功能</th>
</tr>
</thead>
<tbody>
<tr>
<td>Ctrl+C</td>
<td>终止当前命令</td>
</tr>
<tr>
<td>Ctrl+D</td>
<td>退出当前 Shell（等于 exit）</td>
</tr>
<tr>
<td>Ctrl+L</td>
<td>清屏（等于 clear）</td>
</tr>
<tr>
<td>Ctrl+A</td>
<td>光标移到行首</td>
</tr>
<tr>
<td>Ctrl+E</td>
<td>光标移到行尾</td>
</tr>
<tr>
<td>Ctrl+U</td>
<td>删除光标前所有内容</td>
</tr>
<tr>
<td>Ctrl+K</td>
<td>删除光标后所有内容</td>
</tr>
<tr>
<td>Ctrl+R</td>
<td>搜索历史命令</td>
</tr>
<tr>
<td>Tab</td>
<td>自动补全</td>
</tr>
<tr>
<td>Tab Tab</td>
<td>显示所有匹配项</td>
</tr>
</tbody>
</table>
<hr />
<p><strong>命令历史：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">history                    # 显示历史命令
history 20                 # 显示最近 20 条
!10                        # 执行第 10 条历史命令
!ls                        # 执行最近的 ls 命令
!!                         # 执行上一条命令
Ctrl+R                     # 搜索历史命令</code></pre>
<p>历史命令保存在 <code>~/.bash_history</code>。</p>
<hr />
<p><strong>命令别名：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">alias                      # 显示所有别名
alias ll='ls -lah'         # 设置别名
unalias ll                 # 删除别名</code></pre>
<p>永久生效：写入 <code>~/.bashrc</code>。</p>
<hr />
<p><strong>管道和重定向：</strong></p>
<p>管道 <code>|</code>：把前一个命令的输出传给后一个命令：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ls | grep txt              # ls 结果传给 grep 搜索
ps aux | grep nginx        # 进程列表传给 grep
cat file.txt | sort | uniq # 文件内容排序去重</code></pre>
<p>重定向：把输出写入文件：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">command &gt; file.txt         # 输出到文件（覆盖）
command &gt;&gt; file.txt        # 输出到文件（追加）
command 2&gt; error.txt       # 错误输出到文件
command &gt; file.txt 2&gt;&amp;1    # 标准输出和错误输出都写入文件
command &lt; input.txt        # 从文件读取输入</code></pre>
<hr />
<h3>5.4 通配符</h3>
<p>匹配文件名：</p>
<table>
<thead>
<tr>
<th>通配符</th>
<th>含义</th>
<th>例子</th>
</tr>
</thead>
<tbody>
<tr>
<td>*</td>
<td>匹配任意字符</td>
<td><code>*.txt</code> 匹配所有 txt 文件</td>
</tr>
<tr>
<td>?</td>
<td>匹配单个字符</td>
<td><code>file?.txt</code> 匹配 file1.txt、fileA.txt</td>
</tr>
<tr>
<td>[]</td>
<td>匹配指定字符</td>
<td><code>file[1-3].txt</code> 匹配 file1.txt、file2.txt、file3.txt</td>
</tr>
<tr>
<td>{}</td>
<td>匹配多个选项</td>
<td><code>file{1,2,3}.txt</code> 匹配三个文件</td>
</tr>
</tbody>
</table>
<p>例子：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ls *.txt                   # 查看所有 txt 文件
rm file[1-5].txt           # 删除 file1 到 file5
cp *.jpg /home/backup/     # 复制所有 jpg 文件</code></pre>
<hr />
<h3>5.5 环境变量</h3>
<p>环境变量是 Shell 运行时的参数，影响程序行为。</p>
<p><strong>常用环境变量：</strong></p>
<table>
<thead>
<tr>
<th>变量</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>PATH</td>
<td>命令搜索路径</td>
</tr>
<tr>
<td>HOME</td>
<td>用户主目录</td>
</tr>
<tr>
<td>USER</td>
<td>当前用户名</td>
</tr>
<tr>
<td>SHELL</td>
<td>当前 Shell</td>
</tr>
<tr>
<td>PWD</td>
<td>当前目录</td>
</tr>
<tr>
<td>LANG</td>
<td>语言设置</td>
</tr>
<tr>
<td>PS1</td>
<td>命令提示符格式</td>
</tr>
</tbody>
</table>
<p><strong>查看环境变量：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">echo $PATH                 # 显示 PATH
env                        # 显示所有环境变量
printenv PATH              # 显示指定变量</code></pre>
<p><strong>设置环境变量：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">export VAR=value           # 设置临时环境变量
VAR=value                  # 设置 Shell 变量（不导出）
export PATH=$PATH:/new/path    # 添加路径到 PATH</code></pre>
<p><strong>永久设置：</strong></p>
<p>写入配置文件：</p>
<ul>
<li><code>~/.bashrc</code>：用户级别，登录时加载</li>
<li><code>~/.bash_profile</code>：用户级别，登录时加载（优先）</li>
<li><code>/etc/profile</code>：系统级别，所有用户</li>
<li><code>/etc/environment</code>：系统环境变量</li>
</ul>
<p>例子（写入 ~/.bashrc）：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">export JAVA_HOME=/usr/lib/jvm/java-11
export PATH=$PATH:$JAVA_HOME/bin</code></pre>
<p>加载配置：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">source ~/.bashrc           # 立即生效</code></pre>
<hr />
<h2>六、软件安装和管理</h2>
<h3>6.1 Linux 软件安装方式</h3>
<p>Linux 安装软件主要有三种方式：</p>
<p><strong>（1）包管理器安装</strong></p>
<p>最推荐的方式，自动处理依赖关系。</p>
<ul>
<li>CentOS/RHEL：yum、dnf</li>
<li>Ubuntu/Debian：apt</li>
<li>Arch：pacman</li>
</ul>
<hr />
<p><strong>（2）源码编译安装</strong></p>
<p>下载源码，自己编译。</p>
<p>流程：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">tar -xzvf source.tar.gz    # 解压
cd source                  # 进入目录
./configure                # 配置（检查依赖）
make                       # 编译
make install               # 安装</code></pre>
<p>优点：可以自定义编译选项。<br />
缺点：麻烦，依赖要自己解决。</p>
<hr />
<p><strong>（3）二进制文件安装</strong></p>
<p>下载编译好的可执行文件，直接运行。</p>
<p>例子：下载 Go 语言官方二进制包，解压后就能用。</p>
<hr />
<p><strong>（4）容器化部署</strong></p>
<p>用 Docker 等容器技术，不直接安装软件，而是运行容器。</p>
<hr />
<h3>6.2 包管理器详解</h3>
<p><strong>yum（CentOS 7）</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">yum install package        # 安装
yum remove package         # 删除
yum update                 # 更新所有
yum update package         # 更新指定包
yum search keyword         # 搜索
yum list installed         # 已安装列表
yum info package           # 包信息
yum clean all              # 清理缓存</code></pre>
<p>软件源配置：<code>/etc/yum.repos.d/*.repo</code></p>
<hr />
<p><strong>dnf（CentOS 8+/Fedora）</strong></p>
<p>dnf 是 yum 的升级版，命令基本一样：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">dnf install package
dnf remove package
dnf update
dnf search keyword</code></pre>
<hr />
<p><strong>apt（Ubuntu/Debian）</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">apt update                 # 更新软件源索引
apt install package        # 安装
apt remove package         # 删除（保留配置）
apt purge package          # 删除（包括配置）
apt upgrade                # 升级所有包
apt search keyword         # 搜索
apt show package           # 包信息
apt list --installed       # 已安装列表
apt autoremove             # 清理无用依赖
apt clean                  # 清理缓存</code></pre>
<p>软件源配置：<code>/etc/apt/sources.list</code></p>
<hr />
<h3>6.3 rpm 和 dpkg（底层包工具）</h3>
<p>直接安装 rpm/deb 文件，不自动解决依赖。</p>
<p><strong>rpm：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">rpm -ivh package.rpm       # 安装
rpm -e package             # 删除
rpm -qa                    # 所有已安装包
rpm -qi package            # 包信息
rpm -ql package            # 包安装的文件列表</code></pre>
<hr />
<p><strong>dpkg：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">dpkg -i package.deb        # 安装
dpkg -r package            # 删除（保留配置）
dpkg -P package            # 删除（包括配置）
dpkg -l                    # 已安装列表
dpkg -L package            # 包安装的文件列表</code></pre>
<hr />
<h3>6.4 源码安装详解</h3>
<p><strong>下载源码：</strong></p>
<p>通常从官网或 GitHub 下载 <code>.tar.gz</code> 或 <code>.tar.bz2</code> 文件。</p>
<hr />
<p><strong>解压：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">tar -xzvf package-1.0.tar.gz     # gzip 格式
tar -xjvf package-1.0.tar.bz2    # bzip2 格式</code></pre>
<hr />
<p><strong>进入目录：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">cd package-1.0</code></pre>
<hr />
<p><strong>配置：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">./configure</code></pre>
<p>configure 脚本检查系统环境、依赖库，生成 Makefile。</p>
<p>常用选项：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">./configure --prefix=/usr/local/package    # 指定安装路径
./configure --help                         # 查看可用选项</code></pre>
<p>如果 configure 报错缺少依赖，先安装依赖再重来。</p>
<hr />
<p><strong>编译：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">make</code></pre>
<p>make 根据 Makefile 编译源码。这一步可能比较慢。</p>
<hr />
<p><strong>安装：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">make install</code></pre>
<p>把编译好的文件复制到系统目录（需要 root 权限）。</p>
<hr />
<p><strong>清理：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">make clean                 # 清理编译文件
make distclean             # 清理所有生成的文件</code></pre>
<hr />
<h3>6.5 软件安装位置</h3>
<p>不同安装方式，软件位置不同：</p>
<table>
<thead>
<tr>
<th>安装方式</th>
<th>通常位置</th>
</tr>
</thead>
<tbody>
<tr>
<td>包管理器</td>
<td><code>/usr/bin</code>、<code>/usr/lib</code>、<code>/usr/share</code></td>
</tr>
<tr>
<td>源码安装</td>
<td><code>/usr/local/bin</code>、<code>/usr/local/lib</code></td>
</tr>
<tr>
<td>用户安装</td>
<td><code>~/bin</code>、<code>~/.local/bin</code></td>
</tr>
</tbody>
</table>
<hr />
<h2>七、进程和服务管理</h2>
<h3>7.1 进程概念</h3>
<p>进程是程序的运行实例。一个程序可以有多个进程（比如多个 nginx worker 进程）。</p>
<p><strong>进程属性：</strong></p>
<ul>
<li>PID：进程 ID，唯一标识</li>
<li>PPID：父进程 ID</li>
<li>User：运行进程的用户</li>
<li>State：进程状态（运行、睡眠、停止等）</li>
<li>CPU：CPU 使用率</li>
<li>Memory：内存使用量</li>
</ul>
<p><strong>进程状态：</strong></p>
<table>
<thead>
<tr>
<th>状态</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>R</td>
<td>运行或就绪</td>
</tr>
<tr>
<td>S</td>
<td>睡眠（等待事件）</td>
</tr>
<tr>
<td>D</td>
<td>不可中断睡眠（等待 IO）</td>
</tr>
<tr>
<td>Z</td>
<td>僵尸进程（已结束但未被回收）</td>
</tr>
<tr>
<td>T</td>
<td>停止（被暂停）</td>
</tr>
</tbody>
</table>
<hr />
<h3>7.2 查看进程</h3>
<p><strong>ps 命令：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ps                         # 当前用户进程
ps aux                     # 所有进程详细信息
ps -ef                     # 另一种格式
ps aux | grep nginx        # 搜索进程</code></pre>
<p>输出解释：</p>
<ul>
<li>USER：用户</li>
<li>PID：进程 ID</li>
<li>%CPU：CPU 使用率</li>
<li>%MEM：内存使用率</li>
<li>STAT：进程状态</li>
<li>COMMAND：命令</li>
</ul>
<hr />
<p><strong>top 命令：</strong></p>
<p>实时监控进程：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">top</code></pre>
<p>进入 top 后：</p>
<ul>
<li>按 P：按 CPU 排序</li>
<li>按 M：按内存排序</li>
<li>按 k：杀进程</li>
<li>按 q：退出</li>
</ul>
<hr />
<p><strong>htop 命令：</strong></p>
<p>更友好的进程监控：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">htop</code></pre>
<p>能鼠标操作，支持横向滚动，比 top 好用。</p>
<hr />
<p><strong>pgrep 命令：</strong></p>
<p>查找进程 PID：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">pgrep nginx                # 查找 nginx 进程
pgrep -u root nginx        # root 用户运行的 nginx</code></pre>
<hr />
<h3>7.3 进程管理</h3>
<p><strong>启动进程：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">./program                  # 前台运行
./program &amp;                # 后台运行
nohup ./program &amp;          # 后台运行，不因终端关闭而终止</code></pre>
<hr />
<p><strong>终止进程：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">kill PID                   # 正常终止
kill -9 PID                # 强制终止
killall name               # 按名字杀死
pkill name                 # 按名字杀死</code></pre>
<hr />
<p><strong>进程前后台切换：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">Ctrl+Z                     # 暂停前台进程（放入后台）
jobs                       # 查看后台作业
bg %1                      # 让作业 1 在后台继续
fg %1                      # 把作业 1 调到前台</code></pre>
<hr />
<h3>7.4 服务概念</h3>
<p>服务是长期运行的进程，通常在后台，响应请求。</p>
<p>比如：</p>
<ul>
<li>nginx：Web 服务</li>
<li>mysql：数据库服务</li>
<li>sshd：SSH 服务</li>
</ul>
<hr />
<h3>7.5 服务管理（systemd）</h3>
<p>现代 Linux 用 systemd 管理服务。</p>
<p><strong>常用命令：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">systemctl start service    # 启动服务
systemctl stop service     # 停止服务
systemctl restart service  # 重启服务
systemctl status service   # 查看状态
systemctl enable service   # 设置开机自启
systemctl disable service  # 关闭开机自启
systemctl is-enabled service   # 查看是否开机自启
systemctl list-units --type=service   # 所有服务列表
systemctl daemon-reload    # 重载配置（修改配置后）</code></pre>
<hr />
<p><strong>服务配置文件：</strong></p>
<p>服务配置文件在 <code>/etc/systemd/system/</code> 或 <code>/usr/lib/systemd/system/</code>。</p>
<p>格式示例（nginx.service）：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target

[Service]
Type=forking
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/usr/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target</code></pre>
<hr />
<h3>7.6 传统服务管理（CentOS 6）</h3>
<p>老版本用 service 和 chkconfig：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">service nginx start        # 启动
service nginx stop         # 停止
service nginx restart      # 重启
service nginx status       # 状态

chkconfig nginx on         # 开机自启
chkconfig nginx off        # 关闭自启
chkconfig --list           # 查看所有服务状态</code></pre>
<hr />
<h3>7.7 日志查看</h3>
<p><strong>journalctl（systemd 日志）：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">journalctl                 # 所有日志
journalctl -u nginx        # nginx 服务日志
journalctl -f              # 实时查看
journalctl --since today   # 今天日志
journalctl -p err          # 只看错误级别</code></pre>
<hr />
<p><strong>传统日志文件：</strong></p>
<p>日志在 <code>/var/log/</code>：</p>
<ul>
<li><code>/var/log/messages</code>：系统主日志（CentOS）</li>
<li><code>/var/log/syslog</code>：系统主日志（Ubuntu）</li>
<li><code>/var/log/auth.log</code>：认证日志（登录记录）</li>
<li><code>/var/log/nginx/error.log</code>：Nginx 错误日志</li>
<li><code>/var/log/mysql/error.log</code>：MySQL 错误日志</li>
</ul>
<hr />
<h2>八、网络基础知识</h2>
<h3>8.1 网络接口</h3>
<p>Linux 网络接口命名：</p>
<ul>
<li>eth0、eth1：以太网卡（传统命名）</li>
<li>ens33、ens192：新命名规则</li>
<li>lo：本地回环（127.0.0.1）</li>
<li>wlan0：无线网卡</li>
</ul>
<hr />
<h3>8.2 IP 地址配置</h3>
<p><strong>查看 IP：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ip addr                    # 显示所有 IP
ip addr show eth0          # 显示指定接口
ifconfig                   # 传统命令</code></pre>
<hr />
<p><strong>配置 IP：</strong></p>
<p>临时配置：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ip addr add 192.168.1.100/24 dev eth0    # 添加 IP
ip link set eth0 up                      # 启用网卡</code></pre>
<p>永久配置：</p>
<p>CentOS：编辑 <code>/etc/sysconfig/network-scripts/ifcfg-eth0</code></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
ONBOOT=yes</code></pre>
<p>Ubuntu：编辑 <code>/etc/netplan/*.yaml</code>（Ubuntu 18+）</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-yaml">network:
  ethernets:
    eth0:
      addresses: [192.168.1.100/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [8.8.8.8]
  version: 2</code></pre>
<hr />
<h3>8.3 DNS 配置</h3>
<p>DNS 配置文件：<code>/etc/resolv.conf</code></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">nameserver 8.8.8.8
nameserver 114.114.114.114</code></pre>
<hr />
<h3>8.4 网络测试</h3>
<p><strong>ping 测试连通性：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">ping 192.168.1.1           # ping IP
ping www.baidu.com         # ping 域名
ping -c 5 192.168.1.1      # ping 5 次</code></pre>
<hr />
<p><strong>traceroute 查看路径：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">traceroute www.baidu.com   # 查看路由路径</code></pre>
<hr />
<p><strong>netstat/ss 查看端口：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">netstat -tunlp             # 查看 TCP/UDP 端口
ss -tunlp                  # 新命令</code></pre>
<hr />
<p><strong>curl 测试 HTTP：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">curl http://www.baidu.com  # 请求网页
curl -I http://www.baidu.com  # 只看响应头</code></pre>
<hr />
<h3>8.5 端口概念</h3>
<p>端口是网络通信的逻辑端点。常用端口：</p>
<table>
<thead>
<tr>
<th>端口</th>
<th>服务</th>
</tr>
</thead>
<tbody>
<tr>
<td>22</td>
<td>SSH</td>
</tr>
<tr>
<td>80</td>
<td>HTTP</td>
</tr>
<tr>
<td>443</td>
<td>HTTPS</td>
</tr>
<tr>
<td>21</td>
<td>FTP</td>
</tr>
<tr>
<td>3306</td>
<td>MySQL</td>
</tr>
<tr>
<td>6379</td>
<td>Redis</td>
</tr>
<tr>
<td>8080</td>
<td>Tomcat/备用HTTP</td>
</tr>
</tbody>
</table>
<hr />
<h2>九、系统启动和关机</h2>
<h3>9.1 启动过程</h3>
<p>Linux 启动流程：</p>
<ol>
<li><strong>BIOS/UEFI</strong>：硬件自检，选择启动设备</li>
<li><strong>MBR/GPT</strong>：读取启动分区</li>
<li><strong>GRUB</strong>：引导加载器，选择启动内核</li>
<li><strong>内核</strong>：加载内核，初始化硬件</li>
<li><strong>systemd</strong>：启动第一个进程（PID 1），管理服务</li>
<li><strong>用户登录</strong>：进入登录界面</li>
</ol>
<hr />
<h3>9.2 运行级别</h3>
<p>运行级别定义系统运行模式：</p>
<table>
<thead>
<tr>
<th>级别</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>关机</td>
</tr>
<tr>
<td>1</td>
<td>单用户模式（维护）</td>
</tr>
<tr>
<td>2</td>
<td>多用户（无网络）</td>
</tr>
<tr>
<td>3</td>
<td>多用户（有网络，无图形）</td>
</tr>
<tr>
<td>4</td>
<td>未定义</td>
</tr>
<tr>
<td>5</td>
<td>多用户（有图形）</td>
</tr>
<tr>
<td>6</td>
<td>重启</td>
</tr>
</tbody>
</table>
<p>systemd 用 target 替代：</p>
<ul>
<li><code>multi-user.target</code>：等于级别 3</li>
<li><code>graphical.target</code>：等于级别 5</li>
</ul>
<p>查看：</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">systemctl get-default      # 查看默认 target
systemctl set-default multi-user.target    # 设置默认</code></pre>
<hr />
<h3>9.3 关机和重启</h3>
<p><strong>关机：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">shutdown -h now            # 立即关机
shutdown -h +10            # 10分钟后关机
shutdown -c                # 取消关机
poweroff                   # 立即关机</code></pre>
<p><strong>重启：</strong></p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono language-bash">reboot                     # 重启
shutdown -r now            # 立即重启</code></pre>
<hr />
<h2>十、常用配置文件详解</h2>
<h3>10.1 用户相关</h3>
<p><strong><code>/etc/passwd</code></strong>：用户信息</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">root:x:0:0:root:/root:/bin/bash</code></pre>
<p>格式：用户名:密码占位:UID:GID:描述:主目录:Shell</p>
<hr />
<p><strong><code>/etc/shadow</code></strong>：密码信息</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">root:$6$xxx:18000:0:99999:7:::</code></pre>
<p>格式：用户名:加密密码:上次修改天数:最小天数:最大天数:警告天数: inactive天数:过期天数:保留</p>
<hr />
<p><strong><code>/etc/group</code></strong>：组信息</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">root:x:0:user1,user2</code></pre>
<p>格式：组名:密码占位:GID:成员列表</p>
<hr />
<h3>10.2 网络相关</h3>
<p><strong><code>/etc/hosts</code></strong>：本地域名解析</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">127.0.0.1       localhost
192.168.1.100   myserver</code></pre>
<hr />
<p><strong><code>/etc/resolv.conf</code></strong>：DNS 配置</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">nameserver 8.8.8.8
nameserver 114.114.114.114</code></pre>
<hr />
<p><strong><code>/etc/sysconfig/network-scripts/ifcfg-eth0</code></strong>：网络接口配置（CentOS）</p>
<hr />
<h3>10.3 系统相关</h3>
<p><strong><code>/etc/fstab</code></strong>：磁盘挂载配置</p>
<pre class="overflow-auto rounded-lg border border-border bg-muted p-3 text-sm text-foreground"><code class="font-mono ">/dev/sda1   /       ext4    defaults    0 1
/dev/sda2   /home   ext4    defaults    0 2</code></pre>
<p>格式：设备 挂载点 类型 选项 dump pass</p>
<hr />
<p><strong><code>/etc/crontab</code></strong>：系统定时任务配置</p>
<hr />
<p><strong><code>/etc/profile</code></strong>：系统环境变量</p>
<hr />
<h3>10.4 服务相关</h3>
<p><strong><code>/etc/ssh/sshd_config</code></strong>：SSH 服务配置</p>
<p>重要配置：</p>
<ul>
<li>Port 22：SSH 端口</li>
<li>PermitRootLogin yes/no：是否允许 root 登录</li>
<li>PasswordAuthentication yes/no：是否允许密码登录</li>
</ul>
<hr />
<p><strong><code>/etc/sudoers</code></strong>：sudo 权限配置</p>
<hr />
<h2>十一、常见问题和解决思路</h2>
<h3>11.1 权限问题</h3>
<p><strong>症状：</strong> 操作提示 Permission denied</p>
<p><strong>原因：</strong> 当前用户没有权限</p>
<p><strong>解决：</strong></p>
<ol>
<li>检查文件权限：<code>ls -l file</code></li>
<li>用 sudo 执行：<code>sudo command</code></li>
<li>修改权限：<code>chmod</code></li>
<li>修改所有者：<code>chown</code></li>
</ol>
<hr />
<h3>11.2 命令找不到</h3>
<p><strong>症状：</strong> Command not found</p>
<p><strong>原因：</strong> 命令未安装或不在 PATH</p>
<p><strong>解决：</strong></p>
<ol>
<li>检查命令是否存在：<code>which command</code></li>
<li>安装命令：<code>yum install package</code> 或 <code>apt install package</code></li>
<li>检查 PATH：<code>echo $PATH</code></li>
<li>添加路径到 PATH：<code>export PATH=$PATH:/new/path</code></li>
</ol>
<hr />
<h3>11.3 端口被占用</h3>
<p><strong>症状：</strong> 服务启动失败，提示端口被占用</p>
<p><strong>解决：</strong></p>
<ol>
<li>查看端口占用：<code>netstat -tunlp | grep 端口</code></li>
<li>杀掉占用进程：<code>kill PID</code></li>
<li>更换服务端口</li>
</ol>
<hr />
<h3>11.4 磁盘空间不足</h3>
<p><strong>症状：</strong> 无法创建文件，提示 No space left</p>
<p><strong>解决：</strong></p>
<ol>
<li>查看磁盘使用：<code>df -h</code></li>
<li>查找大文件：<code>du -sh * | sort -rh | head -10</code></li>
<li>清理日志：<code>rm /var/log/*.log</code>（谨慎）</li>
<li>清理缓存：<code>yum clean all</code> 或 <code>apt clean</code></li>
<li>检查 inode：<code>df -i</code></li>
</ol>
<hr />
<h3>11.5 服务无法启动</h3>
<p><strong>解决：</strong></p>
<ol>
<li>查看状态：<code>systemctl status service</code></li>
<li>查看日志：<code>journalctl -u service</code></li>
<li>检查配置文件语法</li>
<li>检查依赖服务是否启动</li>
</ol>
<hr />
<h3>11.6 SSH 无法登录</h3>
<p><strong>解决：</strong></p>
<ol>
<li>检查 SSH 服务：<code>systemctl status sshd</code></li>
<li>检查端口：<code>netstat -tunlp | grep 22</code></li>
<li>检查防火墙：<code>firewall-cmd --list-all</code></li>
<li>检查配置：<code>/etc/ssh/sshd_config</code></li>
<li>查看日志：<code>journalctl -u sshd</code> 或 <code>/var/log/auth.log</code></li>
</ol>
<hr />
<h2>十二、学习建议</h2>
<h3>12.1 入门路径</h3>
<p>建议学习顺序：</p>
<ol>
<li><strong>安装一个 Linux 系统</strong>：Ubuntu 或 Rocky Linux</li>
<li><strong>熟悉终端操作</strong>：cd、ls、mkdir、rm、cp、mv</li>
<li><strong>理解文件系统</strong>：目录结构和文件路径</li>
<li><strong>学习权限管理</strong>：chmod、chown、sudo</li>
<li><strong>掌握常用命令</strong>：grep、find、tar、vim</li>
<li><strong>了解服务管理</strong>：systemctl</li>
<li><strong>学习 Shell 脚本</strong>：编写自动化脚本</li>
</ol>
<hr />
<h3>12.2 实践建议</h3>
<ol>
<li><strong>不要怕出错</strong>：Linux 错误提示很明确，看错误信息就能知道问题</li>
<li><strong>多用命令手册</strong>：<code>man command</code> 查看详细说明</li>
<li><strong>记录常用命令</strong>：建立自己的命令速查表</li>
<li><strong>搭建实验环境</strong>：用虚拟机或云服务器练习</li>
<li><strong>遇到问题先查日志</strong>：日志能告诉你发生了什么</li>
</ol>
<hr />
<h3>12.3 进阶方向</h3>
<p>掌握基础后，可以学习：</p>
<ul>
<li>Shell 脚本编程</li>
<li>系统运维（监控、备份、安全）</li>
<li>服务部署（Web、数据库、容器）</li>
<li>自动化工具（Ansible、Docker）</li>
</ul>
<hr />
<h2>结语</h2>
<p>这篇把 Linux 的基础知识梳理了一遍：什么是 Linux、发行版怎么选、文件系统结构、用户权限管理、Shell 操作、软件安装、进程服务、网络配置……理解了这些，对 Linux 就有了整体认知。</p>
<p>Linux 不难，难的是一开始的不习惯。多练多用，很快就能上手。遇到问题先看错误信息，再查手册或搜索，大部分问题都能解决。</p>
<p>建议先收藏这篇，以后遇到问题可以对照查阅。</p>
<p><a href="https://www.dixunblog.cn/1748.html">Linux 基础知识完全指南：从零开始理解 Linux 系统</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1748.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Python 网络爬虫入门实战 &#8211; 实战篇</title>
		<link>https://www.dixunblog.cn/1455.html</link>
					<comments>https://www.dixunblog.cn/1455.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Mon, 30 Mar 2026 02:05:58 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[编程代码]]></category>
		<category><![CDATA[Python 教程]]></category>
		<category><![CDATA[python-crawler]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1455.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Python 实战教程！今天我们来学习 Python 网络爬虫入门实战。</p>
<p>一、环境准备</p>
<p><code class="language-bash">pip install requests beautifulsoup4 lxml</p>
<p>二、基础请求</p>
<p>&#60;code class=&#34;language-python...</p>
<p><a href="https://www.dixunblog.cn/1455.html">Python 网络爬虫入门实战 &#8211; 实战篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 Python 实战教程！今天我们来学习 Python 网络爬虫入门实战。</p>
<h2><img decoding="async" class="alignnone size-full wp-image-1457" src="http://cdn.hyclive.cn/dixunblog/2026/03/生成-Python-爬虫入门实战图片.png" alt="" width="2730" height="1535" /></h2>
<h2>一、环境准备</h2>
<pre><code class="language-bash">pip install requests beautifulsoup4 lxml</code></pre>
<h2>二、基础请求</h2>
<pre><code class="language-python">import requests

# GET 请求
response = requests.get('https://www.example.com')
print(response.status_code)
print(response.text)</code></pre>
<h2>三、解析 HTML</h2>
<pre><code class="language-python">from bs4 import BeautifulSoup

html = '''</code></pre>
<h1>标题</h1>
<pre><code class="language-python"></code></pre>
<p>&#8221;&#8217; soup = BeautifulSoup(html, &#8216;lxml&#8217;) print(soup.h1.text)</p>
<pre><code class="language-python"></code></pre>
<h2>四、实战示例</h2>
<pre><code class="language-python"># 爬取新闻标题
import requests
from bs4 import BeautifulSoup

url = 'https://news.example.com'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'lxml')

headlines = soup.find_all('h2', class_='headline')
for h in headlines:
    print(h.text)</code></pre>
<h2>五、注意事项</h2>
<ol>
<li>遵守 robots.txt 协议</li>
<li>控制请求频率</li>
<li>使用 User-Agent</li>
<li>合法合规使用数据</li>
</ol>
<h2>六、总结</h2>
<p>网络爬虫是 Python 实战的重要应用。建议多实践。</p>
<hr />
<p><em>关注我们获取更多 Python 实战教程！</em></p>
<p><a href="https://www.dixunblog.cn/1455.html">Python 网络爬虫入门实战 &#8211; 实战篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1455.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Python 文件批量处理与自动化 &#8211; 进阶篇</title>
		<link>https://www.dixunblog.cn/1454.html</link>
					<comments>https://www.dixunblog.cn/1454.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Mon, 30 Mar 2026 02:05:57 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[编程代码]]></category>
		<category><![CDATA[Python 教程]]></category>
		<category><![CDATA[python-file]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1454.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Python 实战教程！今天我们来深入学习 Python 文件批量处理与自动化。这是每个 Python 开发者都必须掌握的核心技能。无论是处理日志文件、批量重命名、数据清洗。还是自动化办公。都离不开文件操作。</p>
<p>一、文件读写基础</p>
<p>1.1 打开文件的正确方式<br />
Python 使用 open() 函数打开文...</p>
<p><a href="https://www.dixunblog.cn/1454.html">Python 文件批量处理与自动化 &#8211; 进阶篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 Python 实战教程！今天我们来深入学习 Python 文件批量处理与自动化。这是每个 Python 开发者都必须掌握的核心技能。无论是处理日志文件、批量重命名、数据清洗。还是自动化办公。都离不开文件操作。</p>
<h2><img decoding="async" class="alignnone size-full wp-image-1442" src="http://cdn.hyclive.cn/dixunblog/2026/03/生成Python办公插图.png" alt="" width="2730" height="1535" /></h2>
<h2>一、文件读写基础</h2>
<h3>1.1 打开文件的正确方式</h3>
<p>Python 使用 <code>open()</code> 函数打开文件。推荐使用 <code>with</code> 语句。它会自动关闭文件：</p>
<pre><code class="language-python"># 推荐方式 - with 语句自动关闭文件
with open('data.txt', 'r', encoding='utf-8') as f:
    content = f.read()
# 文件自动关闭。无需手动 f.close()

# 不推荐 - 需要手动关闭
f = open('data.txt', 'r', encoding='utf-8')
content = f.read()
f.close()  # 忘记关闭会导致资源泄漏</code></pre>
<h3>1.2 文件打开模式详解</h3>
<table class="wp-block-table">
<thead>
<tr>
<th>模式</th>
<th>说明</th>
<th>文件不存在</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>'r'</code></td>
<td>只读（默认）</td>
<td>报错</td>
</tr>
<tr>
<td><code>'w'</code></td>
<td>写入（清空原文件）</td>
<td>创建新文件</td>
</tr>
<tr>
<td><code>'a'</code></td>
<td>追加（在末尾添加）</td>
<td>创建新文件</td>
</tr>
<tr>
<td><code>'x'</code></td>
<td>独占创建</td>
<td>报错（如果已存在）</td>
</tr>
<tr>
<td><code>'b'</code></td>
<td>二进制模式</td>
<td>配合其他模式使用</td>
</tr>
<tr>
<td><code>'t'</code></td>
<td>文本模式（默认）</td>
<td>配合其他模式使用</td>
</tr>
</tbody>
</table>
<h3>1.3 读取文件的三种方法</h3>
<pre><code class="language-python"># 方法 1：read() - 读取整个文件
with open('data.txt', 'r', encoding='utf-8') as f:
    content = f.read()  # 返回字符串
    print(f"文件大小：{len(content)} 字节")

# 方法 2：readline() - 逐行读取
with open('data.txt', 'r', encoding='utf-8') as f:
    line1 = f.readline()  # 读取第一行
    line2 = f.readline()  # 读取第二行
    print(f"第一行：{line1.strip()}")

# 方法 3：readlines() - 读取所有行到列表
with open('data.txt', 'r', encoding='utf-8') as f:
    lines = f.readlines()  # 返回字符串列表
    print(f"共 {len(lines)} 行")
    for i, line in enumerate(lines, 1):
        print(f"第{i}行：{line.strip()}")

# 推荐：直接迭代文件对象（最省内存）
with open('data.txt', 'r', encoding='utf-8') as f:
    for line_num, line in enumerate(f, 1):
        print(f"第{line_num}行：{line.strip()}")</code></pre>
<h3>1.4 写入文件的多种方式</h3>
<pre><code class="language-python"># 写入模式（会清空原文件）
with open('output.txt', 'w', encoding='utf-8') as f:
    f.write("第一行内容\n")
    f.write("第二行内容\n")
    f.write("第三行内容\n")

# 追加模式（在末尾添加）
with open('output.txt', 'a', encoding='utf-8') as f:
    f.write("追加的内容\n")

# 一次性写入多行
lines = ["苹果\n", "香蕉\n", "橙子\n"]
with open('fruits.txt', 'w', encoding='utf-8') as f:
    f.writelines(lines)  # 注意：需要自己添加换行符

# 使用 print 写入文件
with open('output.txt', 'w', encoding='utf-8') as f:
    print("第一行", file=f)
    print("第二行", file=f)
    print(f"变量值：{42}", file=f)</code></pre>
<h2>二、pathlib &#8211; 现代化的路径操作</h2>
<h3>2.1 Path 对象基础</h3>
<pre><code class="language-python">from pathlib import Path

# 创建路径对象
p = Path('/home/user/documents/report.txt')

# 路径组成部分
print(p.parent)        # /home/user/documents（父目录）
print(p.name)          # report.txt（文件名）
print(p.stem)          # report（不含扩展名）
print(p.suffix)        # .txt（扩展名）
print(p.suffixes)      # ['.txt']（所有扩展名）

# 路径拼接（推荐方式）
base = Path('/home/user')
subdir = base / 'documents' / '2026'
file_path = subdir / 'report.txt'
print(file_path)  # /home/user/documents/2026/report.txt</code></pre>
<h3>2.2 路径判断与转换</h3>
<pre><code class="language-python">from pathlib import Path

p = Path('/home/user/documents')

# 路径判断
print(p.exists())        # 是否存在
print(p.is_file())       # 是否是文件
print(p.is_dir())        # 是否是目录
print(p.is_absolute())   # 是否是绝对路径

# 路径转换
print(p.absolute())      # 转为绝对路径
print(p.resolve())       # 解析符号链接后的绝对路径
print(p.relative_to('/home/user'))  # documents

# 获取当前工作目录
cwd = Path.cwd()
print(f"当前目录：{cwd}")

# 获取家目录
home = Path.home()
print(f"家目录：{home}")</code></pre>
<h2>三、批量处理文件实战</h2>
<h3>3.1 遍历目录树</h3>
<pre><code class="language-python">import os
from pathlib import Path

# 方法 1：os.walk() - 遍历目录树
for root, dirs, files in os.walk('./documents'):
    print(f"当前目录：{root}")
    print(f"子目录：{dirs}")
    print(f"文件：{files}")
    print("-" * 40)

# 方法 2：Path.glob() - 模式匹配
doc_dir = Path('./documents')

# 查找所有.txt 文件
txt_files = list(doc_dir.glob('*.txt'))
print(f"找到 {len(txt_files)} 个 txt 文件")

# 递归查找所有子目录中的.txt 文件
all_txt = list(doc_dir.rglob('*.txt'))
print(f"递归找到 {len(all_txt)} 个 txt 文件")

# 查找特定模式的文件
py_files = list(doc_dir.glob('**/*.py'))  # ** 表示递归
print(f"找到 {len(py_files)} 个 Python 文件")</code></pre>
<h3>3.2 批量重命名文件</h3>
<pre><code class="language-python">from pathlib import Path

# 批量重命名：给所有文件添加前缀
doc_dir = Path('./documents')
for file in doc_dir.glob('*.txt'):
    new_name = f"backup_{file.name}"
    file.rename(file.parent / new_name)
    print(f"重命名：{file.name} -&gt; {new_name}")

# 批量修改扩展名
for file in doc_dir.glob('*.txt'):
    new_name = file.with_suffix('.md')
    file.rename(new_name)
    print(f"修改扩展名：{file.name} -&gt; {new_name.name}")

# 按序号重命名
for i, file in enumerate(doc_dir.glob('*.md'), 1):
    new_name = file.parent / f"document_{i:03d}.md"
    file.rename(new_name)
    print(f"重命名：{file.name} -&gt; {new_name.name}")</code></pre>
<h3>3.3 批量读取与处理</h3>
<pre><code class="language-python">from pathlib import Path

# 批量读取多个文件并合并
doc_dir = Path('./documents')
all_content = []

for file in sorted(doc_dir.glob('*.txt')):
    with open(file, 'r', encoding='utf-8') as f:
        content = f.read()
        all_content.append(f"=== {file.name} ===\n{content}")

# 合并写入新文件
with open('merged.txt', 'w', encoding='utf-8') as f:
    f.write('\n'.join(all_content))

print(f"已合并 {len(all_content)} 个文件到 merged.txt")

# 批量统计文件信息
print("\n文件统计：")
for file in sorted(doc_dir.glob('*.txt')):
    stat = file.stat()
    size_kb = stat.st_size / 1024
    print(f"{file.name}: {size_kb:.2f} KB")</code></pre>
<h3>3.4 文件内容搜索与替换</h3>
<pre><code class="language-python">from pathlib import Path
import re

# 批量搜索包含特定关键词的文件
doc_dir = Path('./documents')
keyword = "Python"
matched_files = []

for file in doc_dir.glob('*.txt'):
    with open(file, 'r', encoding='utf-8') as f:
        content = f.read()
        if keyword in content:
            matched_files.append(file.name)
            count = content.count(keyword)
            print(f"{file.name}: 找到 {count} 处匹配")

print(f"\n共 {len(matched_files)} 个文件包含'{keyword}'")

# 批量替换文本
old_text = "旧版本"
new_text = "新版本"

for file in doc_dir.glob('*.txt'):
    with open(file, 'r', encoding='utf-8') as f:
        content = f.read()
    
    if old_text in content:
        new_content = content.replace(old_text, new_text)
        with open(file, 'w', encoding='utf-8') as f:
            f.write(new_content)
        print(f"已更新：{file.name}")</code></pre>
<h2>四、高级文件操作</h2>
<h3>4.1 文件复制、移动与删除</h3>
<pre><code class="language-python">from pathlib import Path
import shutil

# 复制文件
src = Path('./source.txt')
dst = Path('./backup/source_copy.txt')
dst.parent.mkdir(parents=True, exist_ok=True)  # 创建目录
shutil.copy2(src, dst)  # copy2 保留元数据
print(f"已复制：{src} -&gt; {dst}")

# 复制整个目录
shutil.copytree('./docs', './docs_backup')
print("已复制整个目录")

# 移动文件
src = Path('./old_location/file.txt')
dst = Path('./new_location/file.txt')
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.move(src, dst)
print(f"已移动：{src} -&gt; {dst}")

# 删除文件
Path('./temp.txt').unlink()  # 删除单个文件
print("已删除 temp.txt")

# 删除整个目录
shutil.rmtree('./old_backup')
print("已删除目录")</code></pre>
<h3>4.2 临时文件处理</h3>
<pre><code class="language-python">import tempfile
from pathlib import Path

# 创建临时文件
with tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt') as f:
    temp_path = f.name
    f.write("临时内容")
    print(f"临时文件：{temp_path}")

# 使用临时文件
with open(temp_path, 'r') as f:
    print(f"读取临时文件：{f.read()}")

# 清理临时文件
Path(temp_path).unlink()
print("已清理临时文件")

# 创建临时目录
with tempfile.TemporaryDirectory() as temp_dir:
    print(f"临时目录：{temp_dir}")
    # 在临时目录中操作
    temp_file = Path(temp_dir) / 'test.txt'
    temp_file.write_text("测试内容")
# 退出 with 后自动清理临时目录</code></pre>
<h3>4.3 文件编码处理</h3>
<pre><code class="language-python">import chardet

# 检测文件编码
def detect_encoding(file_path):
    with open(file_path, 'rb') as f:
        result = chardet.detect(f.read(10000))  # 读取前 10KB
    return result['encoding']

# 批量转换编码
from pathlib import Path

doc_dir = Path('./documents')
for file in doc_dir.glob('*.txt'):
    # 检测编码
    encoding = detect_encoding(file)
    print(f"{file.name}: 检测到编码 {encoding}")
    
    # 读取并转换为 UTF-8
    with open(file, 'r', encoding=encoding) as f:
        content = f.read()
    
    # 写回 UTF-8
    with open(file, 'w', encoding='utf-8') as f:
        f.write(content)
    print(f"已转换：{file.name}")</code></pre>
<h2>五、实战项目</h2>
<h3>5.1 日志文件分析器</h3>
<pre><code class="language-python">from pathlib import Path
from collections import Counter
import re

def analyze_log(log_path):
    '''分析日志文件'''
    log_file = Path(log_path)
    
    error_count = 0
    warning_count = 0
    error_lines = []
    
    with open(log_file, 'r', encoding='utf-8') as f:
        for line_num, line in enumerate(f, 1):
            if 'ERROR' in line:
                error_count += 1
                error_lines.append((line_num, line.strip()))
            elif 'WARNING' in line:
                warning_count += 1
    
    print(f"日志分析结果：")
    print(f"  错误数：{error_count}")
    print(f"  警告数：{warning_count}")
    print(f"\n最新错误：")
    for line_num, line in error_lines[-5:]:
        print(f"  行{line_num}: {line}")

# 使用示例
analyze_log('./app.log')</code></pre>
<h3>5.2 批量图片重命名</h3>
<pre><code class="language-python">from pathlib import Path
from datetime import datetime

def rename_photos(photo_dir, prefix="IMG"):
    '批量重命名照片'
    photo_path = Path(photo_dir)
    
    # 获取所有图片文件
    images = list(photo_path.glob('*.jpg')) + list(photo_path.glob('*.png'))
    images.sort(key=lambda p: p.stat().st_mtime)  # 按修改时间排序
    
    for i, img in enumerate(images, 1):
        # 生成新文件名
        date_str = datetime.fromtimestamp(img.stat().st_mtime).strftime('%Y%m%d')
        new_name = f"{prefix}_{date_str}_{i:04d}{img.suffix}"
        new_path = img.parent / new_name
        
        # 重命名
        img.rename(new_path)
        print(f"{img.name} -&gt; {new_name}")

# 使用示例
rename_photos('./photos', 'VACATION')</code></pre>
<h3>5.3 文件备份工具</h3>
<pre><code class="language-python">from pathlib import Path
import shutil
from datetime import datetime

def backup_files(source_dir, backup_dir, patterns=None):
    '备份指定类型的文件'
    source = Path(source_dir)
    backup = Path(backup_dir)
    
    # 创建带时间戳的备份目录
    timestamp = datetime.now().strftime('%Y%m%d_%H%M%S')
    backup_path = backup / f"backup_{timestamp}"
    backup_path.mkdir(parents=True, exist_ok=True)
    
    # 默认备份所有文件
    if patterns is None:
        patterns = ['*']
    
    # 复制文件
    copied_count = 0
    for pattern in patterns:
        for file in source.glob(pattern):
            if file.is_file():
                dest = backup_path / file.name
                shutil.copy2(file, dest)
                copied_count += 1
    
    print(f"备份完成：{copied_count} 个文件")
    print(f"备份位置：{backup_path}")
    return backup_path

# 使用示例
backup_files('./documents', './backups', ['*.txt', '*.docx', '*.pdf'])</code></pre>
<h2>六、常见错误与解决</h2>
<h3>6.1 文件不存在错误</h3>
<pre><code class="language-python">from pathlib import Path

# 错误：文件不存在会报错
# with open('not_exist.txt', 'r') as f:
#     content = f.read()  # FileNotFoundError!

# 解决：先检查是否存在
file = Path('not_exist.txt')
if file.exists():
    content = file.read_text()
else:
    print("文件不存在。创建新文件")
    file.write_text("初始内容")

# 或使用异常处理
try:
    content = file.read_text()
except FileNotFoundError:
    print("文件不存在。使用默认内容")
    content = "默认内容"</code></pre>
<h3>6.2 编码错误</h3>
<pre><code class="language-python"># 错误：编码不匹配
# with open('file.txt', 'r', encoding='ascii') as f:
#     content = f.read()  # UnicodeDecodeError!

# 解决：使用正确的编码
with open('file.txt', 'r', encoding='utf-8') as f:
    content = f.read()

# 或忽略错误
with open('file.txt', 'r', encoding='utf-8', errors='ignore') as f:
    content = f.read()

# 或替换错误字符
with open('file.txt', 'r', encoding='utf-8', errors='replace') as f:
    content = f.read()</code></pre>
<h3>6.3 权限错误</h3>
<pre><code class="language-python">from pathlib import Path

# 错误：没有写入权限
# Path('/root/protected.txt').write_text("内容")  # PermissionError!

# 解决：检查权限或选择其他目录
file = Path('./user_file.txt')
try:
    file.write_text("内容")
except PermissionError:
    print("没有权限。尝试其他目录")
    file = Path.home() / 'file.txt'
    file.write_text("内容")</code></pre>
<h2>七、最佳实践</h2>
<ol>
<li><strong>始终使用 with 语句</strong>：自动关闭文件。避免资源泄漏</li>
<li><strong>明确指定编码</strong>：始终使用 <code>encoding='utf-8'</code></li>
<li><strong>使用 pathlib</strong>：比 os.path 更现代、更易用</li>
<li><strong>大文件分块读取</strong>：避免一次性加载到内存
<pre><code class="language-python">with open('large_file.txt', 'r') as f:
    for chunk in iter(lambda: f.read(8192), ''):
        process(chunk)</code></pre>
</li>
<li><strong>先创建目录再写入</strong>：
<pre><code class="language-python">output = Path('./output/subdir/file.txt')
output.parent.mkdir(parents=True, exist_ok=True)
output.write_text("内容")</code></pre>
</li>
</ol>
<h2>八、总结与练习</h2>
<p>今天我们深入学习了 Python 文件处理的各个方面。建议：</p>
<ol>
<li><strong>掌握基础</strong>：open()、read()、write()、with 语句</li>
<li><strong>熟练使用 pathlib</strong>：现代化的路径操作</li>
<li><strong>理解编码</strong>：UTF-8 是默认选择</li>
<li><strong>多实践</strong>：通过实际项目巩固知识</li>
</ol>
<h3>课后练习</h3>
<ol>
<li>编写脚本。统计目录下所有代码文件的总行数</li>
<li>实现一个简单的文件搜索工具。支持关键词搜索</li>
<li>编写批量重命名工具。支持添加前缀、后缀、序号</li>
<li>实现日志分析器。提取错误和警告信息</li>
<li>创建自动备份脚本。定期备份重要文件</li>
</ol>
<hr />
<p><em>关注我们获取更多 Python 实战教程！下节课我们将学习 Python 网络爬虫入门。</em></p>
<p><a href="https://www.dixunblog.cn/1454.html">Python 文件批量处理与自动化 &#8211; 进阶篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1454.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Python 自动化办公实战：Excel 处理 &#8211; 基础篇</title>
		<link>https://www.dixunblog.cn/1453.html</link>
					<comments>https://www.dixunblog.cn/1453.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Mon, 30 Mar 2026 02:05:55 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[编程代码]]></category>
		<category><![CDATA[Python 教程]]></category>
		<category><![CDATA[python-excel]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1453.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Python 实战教程！今天我们来学习 Python 自动化办公之 Excel 处理。</p>
<p>一、环境准备</p>
<p>1.1 安装库<br />
<code class="language-bash">pip install openpyxl pandas xlrd xlwt</p>
<p>1.2 库的选择</p>
<p><strong>openpy...</p>
<p><a href="https://www.dixunblog.cn/1453.html">Python 自动化办公实战：Excel 处理 &#8211; 基础篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 Python 实战教程！今天我们来学习 Python 自动化办公之 Excel 处理。</p>
<h2><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1442" src="http://cdn.hyclive.cn/dixunblog/2026/03/生成Python办公插图.png" alt="" width="2730" height="1535" /></h2>
<h2>一、环境准备</h2>
<h3>1.1 安装库</h3>
<pre><code class="language-bash">pip install openpyxl pandas xlrd xlwt</code></pre>
<h3>1.2 库的选择</h3>
<ul>
<li><strong>openpyxl</strong>：读写.xlsx 文件</li>
<li><strong>pandas</strong>：数据处理和分析</li>
<li><strong>xlrd/xlwt</strong>：读写.xls 文件（旧格式）</li>
</ul>
<h2>二、读取 Excel 文件</h2>
<h3>2.1 使用 openpyxl</h3>
<pre><code class="language-python">from openpyxl import load_workbook

# 加载工作簿
wb = load_workbook('data.xlsx')

# 选择工作表
ws = wb['Sheet1']

# 读取单元格
value = ws['A1'].value

# 遍历行
for row in ws.iter_rows():
    for cell in row:
        print(cell.value)</code></pre>
<h3>2.2 使用 pandas</h3>
<pre><code class="language-python">import pandas as pd

# 读取 Excel
df = pd.read_excel('data.xlsx')

# 查看数据
print(df.head())
print(df.columns)

# 选择列
names = df['姓名']</code></pre>
<h2>三、写入 Excel 文件</h2>
<h3>3.1 创建新文件</h3>
<pre><code class="language-python">from openpyxl import Workbook

wb = Workbook()
ws = wb.active
ws.title = "数据表"

# 写入数据
ws['A1'] = "姓名"
ws['B1'] = "年龄"
ws.append(["张三", 25])
ws.append(["李四", 28])

wb.save('output.xlsx')</code></pre>
<h3>3.2 使用 pandas 写入</h3>
<pre><code class="language-python">import pandas as pd

data = {
    '姓名': ['张三', '李四'],
    '年龄': [25, 28],
    '城市': ['北京', '上海']
}

df = pd.DataFrame(data)
df.to_excel('output.xlsx', index=False)</code></pre>
<h2>四、数据处理实战</h2>
<h3>4.1 数据筛选</h3>
<pre><code class="language-python"># 筛选年龄大于 25 的记录
filtered = df[df['年龄'] &gt; 25]

# 多条件筛选
filtered = df[(df['年龄'] &gt; 25) &amp; (df['城市'] == '北京')]</code></pre>
<h3>4.2 数据统计</h3>
<pre><code class="language-python"># 平均值
avg_age = df['年龄'].mean()

# 分组统计
grouped = df.groupby('城市')['年龄'].mean()</code></pre>
<h3>4.3 数据合并</h3>
<pre><code class="language-python"># 合并两个 Excel
df1 = pd.read_excel('file1.xlsx')
df2 = pd.read_excel('file2.xlsx')

# 横向合并
merged = pd.merge(df1, df2, on='姓名')

# 纵向合并
combined = pd.concat([df1, df2])</code></pre>
<h2>五、批量处理</h2>
<h3>5.1 批量读取</h3>
<pre><code class="language-python">import os
import pandas as pd

files = [f for f in os.listdir('.') if f.endswith('.xlsx')]
all_data = []

for file in files:
    df = pd.read_excel(file)
    all_data.append(df)

combined = pd.concat(all_data)</code></pre>
<h3>5.2 批量写入</h3>
<pre><code class="language-python">departments = ['销售部', '技术部', '财务部']

for dept in departments:
    df = get_department_data(dept)
    df.to_excel(f'{dept}_报表.xlsx', index=False)</code></pre>
<h2>六、格式化与样式</h2>
<pre><code class="language-python">from openpyxl.styles import Font, PatternFill

# 设置字体
ws['A1'].font = Font(bold=True, color='FF0000')

# 设置背景色
ws['A1'].fill = PatternFill(start_color='FFFF00', fill_type='solid')

# 设置列宽
ws.column_dimensions['A'].width = 20</code></pre>
<h2>七、总结</h2>
<p>Python 处理 Excel 可以大幅提升办公效率。建议多实践。</p>
<hr />
<p><em>关注我们获取更多 Python 实战教程！</em></p>
<p><a href="https://www.dixunblog.cn/1453.html">Python 自动化办公实战：Excel 处理 &#8211; 基础篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1453.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>单片机入门：点亮第一个 LED (Part 3)</title>
		<link>https://www.dixunblog.cn/1352.html</link>
					<comments>https://www.dixunblog.cn/1352.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Fri, 27 Mar 2026 02:15:23 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[mcu]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1352.html</guid>

					<description><![CDATA[<p>欢迎来到今天的编程教程！今天我们来深入讲解单片机的核心知识点。</p>
<p>一、基础概念</p>
<p>单片机是现代软件开发中最常用的技术之一。掌握它对于每个开发者来说都至关重要。</p>
<p>1.1 核心特性</p>
<p><strong>简洁高效</strong>：代码易读易写，开发效率高<br />
<strong>跨平台</strong>：一次编写，多处运行<br />
&#60;...</p>
<p><a href="https://www.dixunblog.cn/1352.html">单片机入门：点亮第一个 LED (Part 3)</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的编程教程！今天我们来深入讲解单片机的核心知识点。</p>
<h2>一、基础概念</h2>
<p>单片机是现代软件开发中最常用的技术之一。掌握它对于每个开发者来说都至关重要。</p>
<h3>1.1 核心特性</h3>
<ul>
<li><strong>简洁高效</strong>：代码易读易写，开发效率高</li>
<li><strong>跨平台</strong>：一次编写，多处运行</li>
<li><strong>生态丰富</strong>：拥有庞大的第三方库支持</li>
<li><strong>社区活跃</strong>：全球开发者共同维护</li>
</ul>
<h3>1.2 应用场景</h3>
<p>单片机广泛应用于以下领域：</p>
<ol>
<li>Web 后端开发</li>
<li>数据分析与机器学习</li>
<li>自动化脚本</li>
<li>移动应用开发</li>
<li>嵌入式系统</li>
</ol>
<h2>二、实战示例</h2>
<p>让我们通过一个实际例子来理解单片机的使用方法：</p>
<pre><code class="language-python"># 示例代码
def main():
    print("Hello, World!")
    
if __name__ == "__main__":
    main()</code></pre>
<h3>代码解析</h3>
<p>上面的代码展示了单片机的基本结构：</p>
<ul>
<li>函数定义使用 <code>def</code> 关键字</li>
<li>缩进表示代码块</li>
<li><code>if __name__ == "__main__"</code> 是程序入口</li>
</ul>
<h2>三、最佳实践</h2>
<h3>3.1 代码规范</h3>
<p>遵循 PEP 8 等代码规范可以让你的代码更易读：</p>
<ul>
<li>使用有意义的变量名</li>
<li>保持函数短小精悍</li>
<li>添加必要的注释</li>
<li>遵循统一的缩进风格</li>
</ul>
<h3>3.2 错误处理</h3>
<p>良好的错误处理能让程序更健壮：</p>
<pre><code class="language-python">try:
    result = risky_operation()
except Exception as e:
    print("发生错误：" + str(e))
finally:
    cleanup()</code></pre>
<h2>四、学习资源</h2>
<p>想要深入学习单片机？推荐以下资源：</p>
<ul>
<li>官方文档：最权威的学习资料</li>
<li>GitHub 开源项目：实战学习最佳途径</li>
<li>技术博客：了解最佳实践</li>
<li>在线课程：系统化学习</li>
</ul>
<h2>五、总结</h2>
<p>今天我们学习了单片机的基础知识和实战技巧。记住，编程是一门实践性很强的技能，多写代码才能进步更快！</p>
<p>下节课我们将继续深入讲解单片机的高级特性，敬请期待！</p>
<hr />
<p><em>欢迎关注本站获取更多单片机教程和技术分享！</em></p>
<p><a href="https://www.dixunblog.cn/1352.html">单片机入门：点亮第一个 LED (Part 3)</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1352.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>MySQL 索引优化实战</title>
		<link>https://www.dixunblog.cn/1350.html</link>
					<comments>https://www.dixunblog.cn/1350.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Fri, 27 Mar 2026 02:15:20 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1350.html</guid>

					<description><![CDATA[<p>欢迎来到今天的编程教程！今天我们来深入讲解数据库的核心知识点。</p>
<p>一、基础概念</p>
<p>数据库是现代软件开发中最常用的技术之一。掌握它对于每个开发者来说都至关重要。</p>
<p>1.1 核心特性</p>
<p><strong>简洁高效</strong>：代码易读易写，开发效率高<br />
<strong>跨平台</strong>：一次编写，多处运行<br />
&#60;...</p>
<p><a href="https://www.dixunblog.cn/1350.html">MySQL 索引优化实战</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的编程教程！今天我们来深入讲解数据库的核心知识点。</p>
<h2>一、基础概念</h2>
<p>数据库是现代软件开发中最常用的技术之一。掌握它对于每个开发者来说都至关重要。</p>
<h3>1.1 核心特性</h3>
<ul>
<li><strong>简洁高效</strong>：代码易读易写，开发效率高</li>
<li><strong>跨平台</strong>：一次编写，多处运行</li>
<li><strong>生态丰富</strong>：拥有庞大的第三方库支持</li>
<li><strong>社区活跃</strong>：全球开发者共同维护</li>
</ul>
<h3>1.2 应用场景</h3>
<p>数据库广泛应用于以下领域：</p>
<ol>
<li>Web 后端开发</li>
<li>数据分析与机器学习</li>
<li>自动化脚本</li>
<li>移动应用开发</li>
<li>嵌入式系统</li>
</ol>
<h2>二、实战示例</h2>
<p>让我们通过一个实际例子来理解数据库的使用方法：</p>
<pre><code class="language-python"># 示例代码
def main():
    print("Hello, World!")
    
if __name__ == "__main__":
    main()</code></pre>
<h3>代码解析</h3>
<p>上面的代码展示了数据库的基本结构：</p>
<ul>
<li>函数定义使用 <code>def</code> 关键字</li>
<li>缩进表示代码块</li>
<li><code>if __name__ == "__main__"</code> 是程序入口</li>
</ul>
<h2>三、最佳实践</h2>
<h3>3.1 代码规范</h3>
<p>遵循 PEP 8 等代码规范可以让你的代码更易读：</p>
<ul>
<li>使用有意义的变量名</li>
<li>保持函数短小精悍</li>
<li>添加必要的注释</li>
<li>遵循统一的缩进风格</li>
</ul>
<h3>3.2 错误处理</h3>
<p>良好的错误处理能让程序更健壮：</p>
<pre><code class="language-python">try:
    result = risky_operation()
except Exception as e:
    print("发生错误：" + str(e))
finally:
    cleanup()</code></pre>
<h2>四、学习资源</h2>
<p>想要深入学习数据库？推荐以下资源：</p>
<ul>
<li>官方文档：最权威的学习资料</li>
<li>GitHub 开源项目：实战学习最佳途径</li>
<li>技术博客：了解最佳实践</li>
<li>在线课程：系统化学习</li>
</ul>
<h2>五、总结</h2>
<p>今天我们学习了数据库的基础知识和实战技巧。记住，编程是一门实践性很强的技能，多写代码才能进步更快！</p>
<p>下节课我们将继续深入讲解数据库的高级特性，敬请期待！</p>
<hr />
<p><em>欢迎关注本站获取更多数据库教程和技术分享！</em></p>
<p><a href="https://www.dixunblog.cn/1350.html">MySQL 索引优化实战</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1350.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Java 基础语法入门：零基础也能看懂的详细教程</title>
		<link>https://www.dixunblog.cn/1287.html</link>
					<comments>https://www.dixunblog.cn/1287.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Thu, 26 Mar 2026 16:37:35 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[编程代码]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Windows教程]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1287.html</guid>

					<description><![CDATA[<p>Java 作为最流行的编程语言之一，广泛应用于企业开发、Android 应用、大数据等领域。本文从零开始讲解 Java 基础语法，包括变量、数据类型、运算符、控制流程、数组、方法、面向对象等核心概念，适合零基础初学者。</p>
<p><a href="https://www.dixunblog.cn/1287.html">Java 基础语法入门：零基础也能看懂的详细教程</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>Java 作为最流行的编程语言之一，广泛应用于企业开发、Android 应用、大数据等领域。本文将带你从零开始学习 Java 基础语法。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1325" src="http://cdn.hyclive.cn/dixunblog/2026/03/Java-基础语法入门.png" alt="" width="2730" height="1535" /></p>
<h2>一、第一个 Java 程序</h2>
<pre><code class="language-java">public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}</code></pre>
<p>运行结果：</p>
<pre><code>Hello, Java!</code></pre>
<h3>代码解析：</h3>
<ul>
<li><code>public class</code>：定义公共类，类名必须与文件名一致</li>
<li><code>main 方法</code>：程序入口，JVM 从这里开始执行</li>
<li><code>System.out.println()</code>：控制台输出语句</li>
</ul>
<h2>二、变量与数据类型</h2>
<h3>1. 基本数据类型</h3>
<pre><code class="language-java">public class DataType {
    public static void main(String[] args) {
        // 整数类型
        int age = 25;
        long population = 7_000_000_000L;
        
        // 浮点类型
        double price = 99.99;
        float pi = 3.14f;
        
        // 字符类型
        char grade = 'A';
        
        // 布尔类型
        boolean isJavaFun = true;
        
        System.out.println("年龄：" + age);
        System.out.println("价格：" + price);
        System.out.println("等级：" + grade);
        System.out.println("有趣吗：" + isJavaFun);
    }
}</code></pre>
<h3>2. 引用数据类型</h3>
<pre><code class="language-java">String name = "张三";
String city = "北京";

System.out.println(name + "住在" + city);</code></pre>
<h2>三、运算符</h2>
<h3>1. 算术运算符</h3>
<pre><code class="language-java">int a = 10, b = 3;

System.out.println("a + b = " + (a + b));  // 13
System.out.println("a - b = " + (a - b));  // 7
System.out.println("a * b = " + (a * b));  // 30
System.out.println("a / b = " + (a / b));  // 3 (整数除法)
System.out.println("a % b = " + (a % b));  // 1 (取余)</code></pre>
<h3>2. 关系运算符</h3>
<pre><code class="language-java">int x = 5, y = 10;

System.out.println("x == y: " + (x == y));  // false
System.out.println("x != y: " + (x != y));  // true
System.out.println("x &gt; y: " + (x &gt; y));    // false
System.out.println("x &lt; y: " + (x = 5: " + (x &gt;= 5));  // true</code></pre>
<h3>3. 逻辑运算符</h3>
<pre><code class="language-java">boolean a = true, b = false;

System.out.println("a &amp;&amp; b: " + (a &amp;&amp; b));  // false (与)
System.out.println("a || b: " + (a || b));  // true (或)
System.out.println("!a: " + (!a));          // false (非)</code></pre>
<h2>四、控制流程</h2>
<h3>1. if-else 条件语句</h3>
<pre><code class="language-java">import java.util.Scanner;

public class IfExample {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入你的年龄：");
        int age = scanner.nextInt();
        
        if (age &lt; 18) {
            System.out.println("未成年");
        } else if (age &lt; 60) {
            System.out.println("成年人");
        } else {
            System.out.println("老年人");
        }
        
        scanner.close();
    }
}</code></pre>
<h3>2. switch 语句</h3>
<pre><code class="language-java">public class SwitchExample {
    public static void main(String[] args) {
        int day = 3;
        String dayName;
        
        switch (day) {
            case 1:
                dayName = "星期一";
                break;
            case 2:
                dayName = "星期二";
                break;
            case 3:
                dayName = "星期三";
                break;
            case 4:
                dayName = "星期四";
                break;
            case 5:
                dayName = "星期五";
                break;
            case 6:
            case 7:
                dayName = "周末";
                break;
            default:
                dayName = "无效的日期";
        }
        
        System.out.println("今天是：" + dayName);
    }
}</code></pre>
<h3>3. for 循环</h3>
<pre><code class="language-java">public class ForLoop {
    public static void main(String[] args) {
        // 计算 1 到 100 的和
        int sum = 0;
        for (int i = 1; i &lt;= 100; i++) {
            sum += i;
        }
        System.out.println("1 到 100 的和：" + sum);
        
        // 打印 99 乘法表
        for (int i = 1; i &lt;= 9; i++) {
            for (int j = 1; j &lt;= i; j++) {
                System.out.print(j + "×" + i + "=" + (i*j) + "  ");
            }
            System.out.println();
        }
    }
}</code></pre>
<h3>4. while 循环</h3>
<pre><code class="language-java">public class WhileLoop {
    public static void main(String[] args) {
        int count = 1;
        
        while (count &lt;= 5) {
            System.out.println("第 " + count + " 次循环");
            count++;
        }
        
        // do-while 循环
        int num = 1;
        do {
            System.out.println("至少执行一次：" + num);
            num++;
        } while (num &lt;= 3);
    }
}</code></pre>
<h2>五、数组</h2>
<pre><code class="language-java">public class ArrayExample {
    public static void main(String[] args) {
        // 声明并初始化数组
        int[] numbers = {1, 2, 3, 4, 5};
        
        // 访问数组元素
        System.out.println("第一个元素：" + numbers[0]);
        System.out.println("数组长度：" + numbers.length);
        
        // 遍历数组
        System.out.print("所有元素：");
        for (int i = 0; i &lt; numbers.length; i++) {
            System.out.print(numbers[i] + " ");
        }
        System.out.println();
        
        // 增强型 for 循环
        System.out.print("增强 for：");
        for (int num : numbers) {
            System.out.print(num + " ");
        }
        
        // 二维数组
        int[][] matrix = {
            {1, 2, 3},
            {4, 5, 6},
            {7, 8, 9}
        };
        
        System.out.println("\n二维数组：");
        for (int[] row : matrix) {
            for (int val : row) {
                System.out.print(val + " ");
            }
            System.out.println();
        }
    }
}</code></pre>
<h2>六、方法（函数）</h2>
<pre><code class="language-java">public class MethodExample {
    
    // 无返回值方法
    public static void sayHello(String name) {
        System.out.println("你好，" + name + "！");
    }
    
    // 有返回值方法
    public static int add(int a, int b) {
        return a + b;
    }
    
    // 可变参数
    public static int sum(int... numbers) {
        int total = 0;
        for (int num : numbers) {
            total += num;
        }
        return total;
    }
    
    // 递归方法：计算阶乘
    public static long factorial(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        return n * factorial(n - 1);
    }
    
    public static void main(String[] args) {
        sayHello("张三");
        
        int result = add(10, 20);
        System.out.println("10 + 20 = " + result);
        
        System.out.println("1+2+3+4+5 = " + sum(1, 2, 3, 4, 5));
        
        System.out.println("5 的阶乘 = " + factorial(5));
    }
}</code></pre>
<h2>七、面向对象基础</h2>
<h3>1. 类的定义</h3>
<pre><code class="language-java">// 定义一个学生类
class Student {
    // 成员变量
    String name;
    int age;
    String major;
    
    // 构造方法
    public Student(String name, int age, String major) {
        this.name = name;
        this.age = age;
        this.major = major;
    }
    
    // 成员方法
    public void study() {
        System.out.println(name + "正在学习" + major + "专业");
    }
    
    public void introduce() {
        System.out.println("我叫" + name + "，今年" + age + "岁");
    }
}

// 使用类
public class Main {
    public static void main(String[] args) {
        Student s1 = new Student("李四", 20, "计算机科学与技术");
        Student s2 = new Student("王五", 21, "软件工程");
        
        s1.introduce();
        s1.study();
        
        s2.introduce();
        s2.study();
    }
}</code></pre>
<h2>八、实战练习</h2>
<h3>练习 1：猜数字游戏</h3>
<pre><code class="language-java">import java.util.Random;
import java.util.Scanner;

public class GuessNumber {
    public static void main(String[] args) {
        Random random = new Random();
        int target = random.nextInt(100) + 1;
        Scanner scanner = new Scanner(System.in);
        int attempts = 0;
        
        System.out.println("=== 猜数字游戏 ===");
        System.out.println("我已经想好了一个 1-100 之间的数字");
        
        while (true) {
            System.out.print("请猜：");
            int guess = scanner.nextInt();
            attempts++;
            
            if (guess  target) {
                System.out.println("太大了！");
            } else {
                System.out.println("恭喜你猜对了！");
                System.out.println("总共猜了 " + attempts + " 次");
                break;
            }
        }
        
        scanner.close();
    }
}</code></pre>
<h2>总结</h2>
<p>本文涵盖了 Java 基础语法的核心内容：</p>
<ol>
<li>✅ 变量与数据类型</li>
<li>✅ 运算符（算术、关系、逻辑）</li>
<li>✅ 控制流程（if、switch、for、while）</li>
<li>✅ 数组（一维、二维）</li>
<li>✅ 方法定义与调用</li>
<li>✅ 面向对象基础（类与对象）</li>
</ol>
<h3>学习建议：</h3>
<ul>
<li><strong>多敲代码</strong>：把示例代码都亲手敲一遍</li>
<li><strong>多练习</strong>：完成文中的实战练习</li>
<li><strong>理解原理</strong>：不要死记硬背，理解为什么这样写</li>
<li><strong>循序渐进</strong>：基础打牢后再学习高级特性</li>
</ul>
<hr />
<p><strong>下节预告</strong>：《Java 面向对象进阶：继承、封装、多态》</p>
<p><em>如果觉得本文有帮助，欢迎收藏、转发，让更多人看到！有任何问题欢迎在评论区留言讨论。</em></p>
<p><a href="https://www.dixunblog.cn/1287.html">Java 基础语法入门：零基础也能看懂的详细教程</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1287.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C 语言指针详解：从入门到精通的完整指南</title>
		<link>https://www.dixunblog.cn/1286.html</link>
					<comments>https://www.dixunblog.cn/1286.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Thu, 26 Mar 2026 16:34:08 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[编程代码]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1286.html</guid>

					<description><![CDATA[<p>指针是 C 语言的灵魂，也是很多初学者最头疼的概念。本文通过大量实例，带你彻底理解 C 语言指针的核心用法，包括指针基础、数组与指针、函数指针、动态内存分配等。</p>
<p><a href="https://www.dixunblog.cn/1286.html">C 语言指针详解：从入门到精通的完整指南</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>指针是 C 语言的灵魂，也是很多初学者最头疼的概念。本文将通过大量实例，带你彻底理解 C 语言指针的核心用法。</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-1322" src="http://cdn.hyclive.cn/dixunblog/2026/03/C-语言指针主题.png" alt="" width="2730" height="1535" /></p>
<h2>什么是指针？</h2>
<p>简单来说，指针就是一个变量，它存储的是另一个变量的内存地址。想象一下，你家的地址就是一个&#8221;指针&#8221;，通过这个地址可以找到你家。</p>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    int age = 25;        // 定义一个整型变量
    int *p = &amp;age;       // p 是指针，存储 age 的地址
    
    printf("age 的值：%d\n", age);
    printf("age 的地址：%p\n", &amp;age);
    printf("指针 p 的值：%p\n", p);
    printf("指针 p 指向的值：%d\n", *p);
    
    return 0;
}</code></pre>
<p>输出结果：</p>
<pre><code>age 的值：25
age 的地址：0x7fff5fbff6ac
指针 p 的值：0x7fff5fbff6ac
指针 p 指向的值：25</code></pre>
<h2>指针的核心运算符</h2>
<h3>1. 取地址运算符 &amp;</h3>
<pre><code class="language-c">int a = 10;
int *ptr = &amp;a;  // &amp;a 获取变量 a 的地址</code></pre>
<h3>2. 解引用运算符 *</h3>
<pre><code class="language-c">int a = 10;
int *ptr = &amp;a;
printf("%d", *ptr);  // *ptr 获取 ptr 指向的值，输出 10</code></pre>
<h2>指针与数组</h2>
<p>指针和数组有着密切的关系，数组名本质上就是一个常量指针。</p>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    int arr[5] = {1, 2, 3, 4, 5};
    int *ptr = arr;  // ptr 指向数组第一个元素
    
    // 两种访问方式等价
    printf("arr[0] = %d\n", arr[0]);
    printf("*ptr = %d\n", *ptr);
    
    // 指针算术运算
    for(int i = 0; i &lt; 5; i++) {
        printf("arr[%d] = %d\n", i, *(ptr + i));
    }
    
    return 0;
}</code></pre>
<h2>指针与函数</h2>
<h3>1. 指针作为函数参数</h3>
<p>通过指针可以实现&#8221;传地址调用&#8221;，在函数内部修改外部变量的值。</p>
<pre><code class="language-c">#include &lt;stdio.h&gt;

// 交换两个数的值
void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

int main() {
    int x = 10, y = 20;
    swap(&amp;x, &amp;y);
    printf("x = %d, y = %d\n", x, y);  // 输出：x = 20, y = 10
    return 0;
}</code></pre>
<h3>2. 返回指针的函数</h3>
<pre><code class="language-c">// 返回数组中最大值的指针
int* findMax(int arr[], int size) {
    int *maxPtr = &amp;arr[0];
    for(int i = 1; i  *maxPtr) {
            maxPtr = &amp;arr[i];
        }
    }
    return maxPtr;
}</code></pre>
<h2>二级指针</h2>
<p>指针本身也是变量，也有地址，指向指针的指针就是二级指针。</p>
<pre><code class="language-c">#include &lt;stdio.h&gt;

int main() {
    int a = 100;
    int *p1 = &amp;a;      // 一级指针
    int **p2 = &amp;p1;    // 二级指针
    
    printf("a = %d\n", a);
    printf("*p1 = %d\n", *p1);
    printf("**p2 = %d\n", **p2);
    
    return 0;
}</code></pre>
<h2>动态内存分配</h2>
<p>指针最重要的应用之一就是动态内存管理。</p>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int main() {
    // 动态分配数组
    int n = 5;
    int *arr = (int*)malloc(n * sizeof(int));
    
    // 使用动态数组
    for(int i = 0; i &lt; n; i++) {
        arr[i] = (i + 1) * 10;
    }
    
    // 打印结果
    for(int i = 0; i &lt; n; i++) {
        printf("arr[%d] = %d\n", i, arr[i]);
    }
    
    // 释放内存
    free(arr);
    arr = NULL;  // 避免野指针
    
    return 0;
}</code></pre>
<h2>常见指针错误</h2>
<h3>1. 野指针</h3>
<pre><code class="language-c">// 错误示例
int *ptr;  // 未初始化的指针
*ptr = 10; // 危险！ptr 指向未知地址

// 正确做法
int *ptr = NULL;  // 初始化为 NULL
int a = 10;
ptr = &amp;a;         // 再赋值有效地址</code></pre>
<h3>2. 内存泄漏</h3>
<pre><code class="language-c">// 错误示例
int *ptr = (int*)malloc(sizeof(int));
*ptr = 10;
// 忘记 free(ptr)，导致内存泄漏

// 正确做法
int *ptr = (int*)malloc(sizeof(int));
*ptr = 10;
// 使用完毕后
free(ptr);
ptr = NULL;</code></pre>
<h3>3. 悬空指针</h3>
<pre><code class="language-c">// 错误示例
int *getPointer() {
    int local = 100;
    return &amp;local;  // 错误！返回局部变量地址
}

// 正确做法
int *getPointer() {
    int *ptr = (int*)malloc(sizeof(int));
    *ptr = 100;
    return ptr;  // 返回动态分配的内存
}</code></pre>
<h2>实战练习</h2>
<h3>题目 1：字符串反转</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

void reverseString(char *str) {
    char *start = str;
    char *end = str + strlen(str) - 1;
    char temp;
    
    while(start &lt; end) {
        temp = *start;
        *start = *end;
        *end = temp;
        start++;
        end--;
    }
}

int main() {
    char str[] = "Hello, World!";
    printf("原字符串：%s\n", str);
    reverseString(str);
    printf("反转后：%s\n", str);
    return 0;
}</code></pre>
<h3>题目 2：冒泡排序（指针实现）</h3>
<pre><code class="language-c">#include &lt;stdio.h&gt;

void bubbleSort(int *arr, int n) {
    for(int i = 0; i &lt; n - 1; i++) {
        for(int j = 0; j  *(arr + j + 1)) {
                int temp = *(arr + j);
                *(arr + j) = *(arr + j + 1);
                *(arr + j + 1) = temp;
            }
        }
    }
}

int main() {
    int arr[] = {64, 34, 25, 12, 22, 11, 90};
    int n = sizeof(arr) / sizeof(arr[0]);
    
    bubbleSort(arr, n);
    
    printf("排序后：");
    for(int i = 0; i &lt; n; i++) {
        printf("%d ", arr[i]);
    }
    printf("\n");
    
    return 0;
}</code></pre>
<h2>总结</h2>
<p>指针是 C 语言的核心，掌握指针需要大量实践。以下是学习建议：</p>
<ol>
<li><strong>理解概念</strong>：指针就是地址，*和&amp;是核心运算符</li>
<li><strong>多画图</strong>：画出内存图帮助理解指针指向</li>
<li><strong>多练习</strong>：通过实际编程加深理解</li>
<li><strong>注意内存管理</strong>：malloc 和 free 配对使用</li>
<li><strong>避免常见错误</strong>：野指针、内存泄漏、悬空指针</li>
</ol>
<p>指针虽然难，但一旦掌握，你的 C 语言水平会有质的飞跃。加油！💪</p>
<hr />
<p><strong>下节预告</strong>：《数据结构基础：链表与指针的完美结合》</p>
<p><em>如果你觉得本文有帮助，欢迎收藏、转发，让更多人看到！</em></p>
<p><a href="https://www.dixunblog.cn/1286.html">C 语言指针详解：从入门到精通的完整指南</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1286.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
