<?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/tag/%E4%BB%A3%E7%A0%81%E6%95%99%E7%A8%8B/feed" rel="self" type="application/rss+xml" />
	<link>https://www.dixunblog.cn/tag/代码教程</link>
	<description>致力于打造专业的互联网资讯平台</description>
	<lastBuildDate>Mon, 06 Apr 2026 00:30:07 +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/tag/代码教程</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Python 条件判断与循环语句 &#8211; 实战篇</title>
		<link>https://www.dixunblog.cn/1568.html</link>
					<comments>https://www.dixunblog.cn/1568.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Mon, 06 Apr 2026 00:30:07 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Python 教程]]></category>
		<category><![CDATA[python-flow]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1568.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Python 基础教程！今天我们来深入讲解 Python 条件判断与循环语句。</p>
<p>一、条件判断</p>
<p>1.1 if 语句<br />
<code class="language-python">age = 18</p>
<p>if age &#62;= 18:<br />
    print("成年人")<br />
else:<br />
    print("未成年人"...</p>
<p><a href="https://www.dixunblog.cn/1568.html">Python 条件判断与循环语句 &#8211; 实战篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 Python 基础教程！今天我们来深入讲解 Python 条件判断与循环语句。</p>
<h2>一、条件判断</h2>
<h3>1.1 if 语句</h3>
<pre><code class="language-python">age = 18

if age &gt;= 18:
    print("成年人")
else:
    print("未成年人")</code></pre>
<h3>1.2 elif 多条件</h3>
<pre><code class="language-python">score = 85

if score &gt;= 90:
    print("优秀")
elif score &gt;= 80:
    print("良好")
elif score &gt;= 60:
    print("及格")
else:
    print("不及格")</code></pre>
<h2>二、循环语句</h2>
<h3>2.1 for 循环</h3>
<pre><code class="language-python"># 遍历列表
fruits = ["苹果", "香蕉", "橙子"]
for fruit in fruits:
    print(fruit)

# 范围循环
for i in range(5):
    print(i)  # 0 到 4</code></pre>
<h3>2.2 while 循环</h3>
<pre><code class="language-python">count = 0
while count &lt; 5:
    print(count)
    count += 1</code></pre>
<h2>三、循环控制</h2>
<pre><code class="language-python"># break - 跳出循环
for i in range(10):
    if i == 5:
        break
    print(i)  # 0-4

# continue - 跳过本次
for i in range(5):
    if i == 3:
        continue
    print(i)  # 0,1,2,4</code></pre>
<h2>四、实战示例</h2>
<pre><code class="language-python"># 猜数字游戏
import random

number = random.randint(1, 100)
guess = 0

while guess != number:
    guess = int(input("猜一个 1-100 的数字："))
    if guess &gt; number:
        print("太大了")
    elif guess &lt; number:
        print(&quot;太小了&quot;)
    else:
        print(&quot;猜对了！&quot;)</code></pre>
<h2>五、总结</h2>
<p>条件判断和循环是编程的基础。建议多练习。</p>
<hr>
<p><em>关注我们获取更多 Python 教程！</em></p>
<p><a href="https://www.dixunblog.cn/1568.html">Python 条件判断与循环语句 &#8211; 实战篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1568.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Python 运算符与表达式详解 &#8211; 进阶篇</title>
		<link>https://www.dixunblog.cn/1567.html</link>
					<comments>https://www.dixunblog.cn/1567.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Mon, 06 Apr 2026 00:30:05 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Python 教程]]></category>
		<category><![CDATA[python-operator]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1567.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Python 基础教程！今天我们来深入讲解 Python 运算符与表达式。</p>
<p>一、算术运算符</p>
<p>1.1 基本运算<br />
<code class="language-python">a = 10<br />
b = 3</p>
<p>print(a + b)  # 加法：13<br />
print(a - b)  # 减法：7<br />
print(a ...</p>
<p><a href="https://www.dixunblog.cn/1567.html">Python 运算符与表达式详解 &#8211; 进阶篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 Python 基础教程！今天我们来深入讲解 Python 运算符与表达式。</p>
<h2>一、算术运算符</h2>
<h3>1.1 基本运算</h3>
<pre><code class="language-python">a = 10
b = 3

print(a + b)  # 加法：13
print(a - b)  # 减法：7
print(a * b)  # 乘法：30
print(a / b)  # 除法：3.333...
print(a // b) # 整除：3
print(a % b)  # 取余：1
print(a ** b) # 幂运算：1000</code></pre>
<h3>1.2 应用场景</h3>
<pre><code class="language-python"># 计算折扣
price = 100
discount = 0.8
final_price = price * discount

# 判断奇偶
num = 17
if num % 2 == 0:
    print("偶数")
else:
    print("奇数")</code></pre>
<h2>二、比较运算符</h2>
<pre><code class="language-python">x = 5
y = 10

print(x == y)  # 等于：False
print(x != y)  # 不等于：True
print(x &gt; y)   # 大于：False
print(x = 5)  # 大于等于：True
print(y &lt;= 10) # 小于等于：True</code></pre>
<h2>三、逻辑运算符</h2>
<pre><code class="language-python">a = True
b = False

print(a and b)  # 与：False
print(a or b)   # 或：True
print(not a)    # 非：False

# 短路求值
result = False and print("不会执行")
result = True or print("不会执行")</code></pre>
<h2>四、位运算符</h2>
<pre><code class="language-python">a = 60    # 0011 1100
b = 13    # 0000 1101

print(a &amp; b)   # 与：12  (0000 1100)
print(a | b)   # 或：61  (0011 1101)
print(a ^ b)   # 异或：49 (0011 0001)
print(~a)      # 取反：-61
print(a &lt;&gt; 2)  # 右移：15</code></pre>
<h2>五、赋值运算符</h2>
<pre><code class="language-python">x = 10
x += 5   # x = x + 5
x -= 3   # x = x - 3
x *= 2   # x = x * 2
x /= 4   # x = x / 4
x //= 2  # x = x // 2
x %= 3   # x = x % 3
x **= 2  # x = x ** 2</code></pre>
<h2>六、成员运算符</h2>
<pre><code class="language-python">fruits = ["苹果", "香蕉", "橙子"]

print("苹果" in fruits)      # True
print("葡萄" not in fruits)  # True

text = "Hello, Python!"
print("Python" in text)      # True</code></pre>
<h2>七、身份运算符</h2>
<pre><code class="language-python">a = [1, 2, 3]
b = [1, 2, 3]
c = a

print(a == b)    # True（值相等）
print(a is b)    # False（不是同一对象）
print(a is c)    # True（同一对象）
print(a is not b) # True</code></pre>
<h2>八、运算符优先级</h2>
<pre><code class="language-python"># 优先级从高到低
# 1. 括号 ()
# 2. 幂 **
# 3. 正负 +x, -x
# 4. 算术 *, /, //, %
# 5. 算术 +, -
# 6. 比较 ==, !=, &gt;, &lt;
# 7. 逻辑 not, and, or

result = 2 + 3 * 4  # 14。不是 20
result = (2 + 3) * 4  # 20</code></pre>
<h2>九、实战示例</h2>
<pre><code class="language-python"># 计算三角形面积（海伦公式）
import math

a, b, c = 3, 4, 5
s = (a + b + c) / 2
area = math.sqrt(s * (s-a) * (s-b) * (s-c))
print(f"面积：{area}")

# 判断闰年
year = 2024
is_leap = (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
print(f"{year}是闰年：{is_leap}")</code></pre>
<h2>十、总结</h2>
<p>掌握运算符是 Python 编程的基础。建议多练习。</p>
<hr>
<p><em>关注我们获取更多 Python 教程！</em></p>
<p><a href="https://www.dixunblog.cn/1567.html">Python 运算符与表达式详解 &#8211; 进阶篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1567.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Python 变量与数据类型完全指南 &#8211; 基础篇</title>
		<link>https://www.dixunblog.cn/1566.html</link>
					<comments>https://www.dixunblog.cn/1566.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Mon, 06 Apr 2026 00:30:03 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Python 教程]]></category>
		<category><![CDATA[python-basic]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1566.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Python 基础教程！今天我们来深入讲解 Python 变量与数据类型。这是 Python 编程的基石，掌握它们对后续学习至关重要。</p>
<p>一、Python 变量基础</p>
<p>1.1 变量的定义<br />
Python 变量不需要声明类型。直接赋值即可。Python 是动态类型语言。变量的类型在运行时确定：<br />
&#60;code ...</p>
<p><a href="https://www.dixunblog.cn/1566.html">Python 变量与数据类型完全指南 &#8211; 基础篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 Python 基础教程！今天我们来深入讲解 Python 变量与数据类型。这是 Python 编程的基石，掌握它们对后续学习至关重要。</p>
<h2>一、Python 变量基础</h2>
<h3>1.1 变量的定义</h3>
<p>Python 变量不需要声明类型。直接赋值即可。Python 是动态类型语言。变量的类型在运行时确定：</p>
<pre><code class="language-python"># 变量定义 - 无需声明类型
name = "Python"        # 字符串
version = 3.12         # 浮点数
is_awesome = True      # 布尔值
count = 100            # 整数

# 查看变量类型
print(type(name))      # &lt;class 'str'&gt;
print(type(version))   # &lt;class 'float'&gt;
print(type(count))     # &lt;class 'int'&gt;

# 变量可以重新赋值为不同类型
count = "一百"         # 现在变成字符串了
print(type(count))     # &lt;class 'str'&gt;</code></pre>
<h3>1.2 命名规则</h3>
<p>遵循良好的命名规范可以让代码更易读：</p>
<ul>
<li><strong>基本规则</strong>：只能包含字母、数字、下划线</li>
<li><strong>不能以数字开头</strong>：如 1name 是非法的</li>
<li><strong>区分大小写</strong>：Name 和 name 是不同的变量</li>
<li><strong>不能使用 Python 关键字</strong>：如 if、for、while 等</li>
<li><strong>推荐使用小写字母和下划线</strong>：如 user_name、total_count</li>
</ul>
<pre><code class="language-python"># 合法的变量名
user_name = "张三"
age = 25
_total = 100

# 非法的变量名（会报错）
# 1name = "李四"      # 不能以数字开头
# class = "Python"    # 不能使用关键字
# my-name = "王五"    # 不能包含连字符

# 查看 Python 关键字
import keyword
print(keyword.kwlist)  # 打印所有关键字</code></pre>
<h2>二、基本数据类型</h2>
<h3>2.1 数值类型</h3>
<p>Python 支持多种数值类型。包括整数、浮点数和复数：</p>
<pre><code class="language-python"># 整数（int）- 任意精度
age = 25
population = 1400000000  # 14 亿
big_num = 10 ** 100      # 1 后面 100 个零。Python 能处理

# 浮点数（float）- 带小数点
price = 99.99
pi = 3.141592653589793
scientific = 1.23e-4     # 科学计数法。等于 0.000123

# 复数（complex）- 用于科学计算
complex_num = 3 + 4j
print(complex_num.real)  # 3.0（实部）
print(complex_num.imag)  # 4.0（虚部）

# 数值运算
a = 10
b = 3
print(a + b)   # 13（加法）
print(a - b)   # 7（减法）
print(a * b)   # 30（乘法）
print(a / b)   # 3.333...（除法。结果总是浮点数）
print(a // b)  # 3（整除。只取整数部分）
print(a % b)   # 1（取余）
print(a ** b)  # 1000（幂运算。10 的 3 次方）</code></pre>
<h3>2.2 字符串类型</h3>
<p>字符串是 Python 中最常用的数据类型之一：</p>
<pre><code class="language-python"># 字符串定义 - 可以用单引号或双引号
text1 = 'Hello'
text2 = "World"

# 多行字符串（使用三引号）
multiline = '''第一行
第二行
第三行'''

# 字符串拼接
greeting = "Hello" + " " + "Python"
print(greeting)  # Hello Python

# 字符串重复
line = "-" * 50
print(line)  # --------------------------------------------------

# 字符串索引和切片
text = "Python"
print(text[0])    # 'P'（第一个字符）
print(text[-1])   # 'n'（最后一个字符）
print(text[0:3])  # 'Pyt'（切片。不包含结束位置）
print(text[:3])   # 'Pyt'（省略开始位置）
print(text[3:])   # 'hon'（省略结束位置）

# 常用字符串方法
name = "  Python  "
print(name.strip())      # 'Python'（去除两端空格）
print(name.upper())      # '  PYTHON  '（转大写）
print(name.lower())      # '  python  '（转小写）
print(len(name))         # 10（字符串长度）

# 字符串格式化
name = "张三"
age = 25
# f-string（Python 3.6+ 推荐）
print(f"我叫{name}。今年{age}岁")
# format 方法
print("我叫{}。今年{}岁".format(name, age))</code></pre>
<h3>2.3 布尔类型</h3>
<pre><code class="language-python"># 布尔值 - 只有 True 和 False
is_valid = True
is_error = False

# 布尔运算
print(True and False)   # False（与）
print(True or False)    # True（或）
print(not True)         # False（非）

# 比较运算返回布尔值
print(5 &gt; 3)    # True
print(5 == 5)   # True
print(5 != 3)   # True

# 真值测试 - 以下值为 False
print(bool(0))        # False
print(bool(""))       # False
print(bool(None))     # False
print(bool([]))       # False
print(bool({}))       # False

# 其他值都为 True
print(bool(1))        # True
print(bool("a"))      # True
print(bool([1]))      # True</code></pre>
<h2>三、容器数据类型</h2>
<h3>3.1 列表（List）</h3>
<p>列表是最常用的容器类型。可以存储有序的元素集合：</p>
<pre><code class="language-python"># 列表定义
fruits = ["苹果", "香蕉", "橙子"]
numbers = [1, 2, 3, 4, 5]
mixed = [1, "hello", 3.14, True]  # 可以包含不同类型

# 访问元素
print(fruits[0])    # '苹果'
print(fruits[-1])   # '橙子'（最后一个）

# 修改元素
fruits[1] = "葡萄"
print(fruits)  # ['苹果', '葡萄', '橙子']

# 添加元素
fruits.append("西瓜")      # 末尾添加
fruits.insert(1, "香蕉")   # 指定位置插入
fruits.extend(["梨", "桃"])  # 扩展列表

# 删除元素
fruits.remove("苹果")      # 删除指定值
del fruits[0]              # 删除指定位置
last = fruits.pop()        # 弹出最后一个元素

# 列表切片
numbers = [0, 1, 2, 3, 4, 5]
print(numbers[1:4])   # [1, 2, 3]
print(numbers[:3])    # [0, 1, 2]
print(numbers[::2])   # [0, 2, 4]（步长为 2）

# 列表推导式（强大功能）
squares = [x**2 for x in range(10)]
print(squares)  # [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

# 常用列表方法
nums = [3, 1, 4, 1, 5, 9, 2, 6]
print(len(nums))     # 8（长度）
print(max(nums))     # 9（最大值）
print(min(nums))     # 1（最小值）
print(sum(nums))     # 31（求和）
nums.sort()          # 排序
print(nums)          # [1, 1, 2, 3, 4, 5, 6, 9]
print(nums.count(1)) # 2（计数）</code></pre>
<h3>3.2 元组（Tuple）</h3>
<p>元组是不可变的列表。适合存储不应改变的数据：</p>
<pre><code class="language-python"># 元组定义
coordinates = (10, 20)
colors = ("red", "green", "blue")
single = (42,)  # 单元素元组需要逗号

# 访问元素（和列表一样）
print(coordinates[0])  # 10
print(colors[-1])      # 'blue'

# 元组解包
x, y = coordinates
print(x, y)  # 10 20

# 交换变量值
a, b = 1, 2
a, b = b, a
print(a, b)  # 2 1

# 元组不可变（尝试修改会报错）
# coordinates[0] = 100  # TypeError!

# 元组的应用场景
# 1. 函数返回多个值
def get_user():
    return ("张三", 25, "北京")

name, age, city = get_user()

# 2. 字典的键（元组可哈希）
location = {(39.9, 116.4): "北京"}

# 3. 保护数据不被修改
RGB_RED = (255, 0, 0)</code></pre>
<h3>3.3 字典（Dictionary）</h3>
<p>字典是键值对的集合。用于存储映射关系：</p>
<pre><code class="language-python"># 字典定义
person = {
    "name": "张三",
    "age": 25,
    "city": "北京",
    "skills": ["Python", "Java", "Linux"]
}

# 访问值
print(person["name"])        # '张三'
print(person.get("age"))     # 25
print(person.get("email"))   # None（键不存在不报错）
print(person.get("email", "未提供"))  # '未提供'（默认值）

# 添加/修改键值对
person["email"] = "zhangsan@example.com"  # 添加
person["age"] = 26  # 修改

# 删除键值对
del person["city"]
age = person.pop("age")  # 弹出并返回值

# 遍历字典
for key, value in person.items():
    print(f"{key}: {value}")

# 常用操作
print("name" in person)      # True（检查键是否存在）
print(person.keys())         # 所有键
print(person.values())       # 所有值
print(len(person))           # 字典大小

# 字典推导式
squares = {x: x**2 for x in range(5)}
print(squares)  # {0: 0, 1: 1, 2: 4, 3: 9, 4: 16}

# 实际应用 - 统计词频
text = "python is great python is fun"
words = text.split()
freq = {}
for word in words:
    freq[word] = freq.get(word, 0) + 1
print(freq)  # {'python': 2, 'is': 2, 'great': 1, 'fun': 1}</code></pre>
<h3>3.4 集合（Set）</h3>
<p>集合是无序且不重复的元素集合：</p>
<pre><code class="language-python"># 集合定义
unique_nums = {1, 2, 3, 3, 4}
print(unique_nums)  # {1, 2, 3, 4}（自动去重）

# 创建空集合（注意：{}是空字典）
empty_set = set()

# 从列表创建集合（去重）
nums = [1, 2, 2, 3, 3, 3]
unique = set(nums)
print(unique)  # {1, 2, 3}

# 集合运算
a = {1, 2, 3, 4}
b = {3, 4, 5, 6}

print(a | b)  # {1, 2, 3, 4, 5, 6}（并集）
print(a &amp; b)  # {3, 4}（交集）
print(a - b)  # {1, 2}（差集）
print(a ^ b)  # {1, 2, 5, 6}（对称差集）

# 集合方法
a.add(5)           # 添加元素
a.remove(1)        # 删除元素（不存在会报错）
a.discard(10)      # 删除元素（不存在不报错）
print(3 in a)      # True（成员检查）</code></pre>
<h2>四、类型转换</h2>
<pre><code class="language-python"># 显式类型转换
num_str = "123"
num_int = int(num_str)      # 字符串转整数：123
num_float = float("3.14")   # 字符串转浮点：3.14
num_str = str(456)          # 整数转字符串："456"

# 列表、元组、集合互转
my_list = [1, 2, 3]
my_tuple = tuple(my_list)   # 列表转元组
my_set = set(my_list)       # 列表转集合

# 实际应用
# 1. 用户输入处理
age_str = input("请输入年龄：")
age = int(age_str)  # 转整数进行计算

# 2. 数据去重
ids = [1, 2, 2, 3, 3, 3]
unique_ids = list(set(ids))  # [1, 2, 3]

# 3. 数字格式化
price = 99.99
print(f"价格：{int(price)}元")  # 价格：99 元</code></pre>
<h2>五、实战示例</h2>
<h3>5.1 学生信息管理系统</h3>
<pre><code class="language-python"># 使用字典和列表管理学生信息
students = [
    {"name": "张三", "age": 20, "score": 85},
    {"name": "李四", "age": 21, "score": 92},
    {"name": "王五", "age": 19, "score": 78}
]

# 添加学生
new_student = {"name": "赵六", "age": 20, "score": 88}
students.append(new_student)

# 计算平均分
total = sum(s["score"] for s in students)
average = total / len(students)
print(f"平均分：{average:.2f}")

# 找出最高分
best_student = max(students, key=lambda s: s["score"])
print(f"最高分：{best_student['name']} - {best_student['score']}")

# 筛选及格学生
passed = [s for s in students if s["score"] &gt;= 60]
print(f"及格人数：{len(passed)}")</code></pre>
<h3>5.2 购物车程序</h3>
<pre><code class="language-python"># 购物车数据结构
cart = {
    "items": [
        {"name": "iPhone 15", "price": 7999, "quantity": 1},
        {"name": "AirPods", "price": 1299, "quantity": 2}
    ],
    "discount": 0.9  # 9 折优惠
}

# 计算总价
total = 0
for item in cart["items"]:
    item_total = item["price"] * item["quantity"]
    total += item_total

# 应用折扣
final_price = total * cart["discount"]
print(f"原价：{total}元")
print(f"折后价：{final_price:.2f}元")

# 添加商品
cart["items"].append({"name": "充电器", "price": 149, "quantity": 1})</code></pre>
<h2>六、常见错误与解决</h2>
<h3>6.1 类型错误</h3>
<pre><code class="language-python"># 错误：字符串和整数不能直接相加
# result = "年龄：" + 25  # TypeError

# 正确做法
result = "年龄：" + str(25)
result = f"年龄：{25}"  # 推荐</code></pre>
<h3>6.2 索引越界</h3>
<pre><code class="language-python">fruits = ["苹果", "香蕉", "橙子"]
# print(fruits[5])  # IndexError!

# 安全访问
if len(fruits) &gt; 5:
    print(fruits[5])
    
# 或使用切片（不会报错）
print(fruits[5:6])  # []</code></pre>
<h3>6.3 键不存在</h3>
<pre><code class="language-python">person = {"name": "张三"}
# print(person["age"])  # KeyError!

# 安全访问
print(person.get("age"))  # None
print(person.get("age", 0))  # 0（默认值）</code></pre>
<h2>七、最佳实践</h2>
<ol>
<li><strong>使用有意义的变量名</strong>：user_name 比 un 更好</li>
<li><strong>遵循命名规范</strong>：变量用小写 + 下划线</li>
<li><strong>选择合适的数据类型</strong>：不变数据用元组。需要去重用集合</li>
<li><strong>使用类型提示</strong>（Python 3.5+）：
<pre><code class="language-python">def greet(name: str) -&gt; str:
    return f"Hello, {name}"</code></pre>
</li>
<li><strong>善用列表推导式</strong>：简洁但不要太复杂</li>
</ol>
<h2>八、总结与练习</h2>
<p>今天我们学习了 Python 变量和数据类型的核心知识。建议：</p>
<ol>
<li><strong>理解不同数据类型的特点</strong>：何时用列表、元组、字典、集合</li>
<li><strong>掌握容器的使用方法</strong>：增删改查、遍历、推导式</li>
<li><strong>熟练进行类型转换</strong>：int()、str()、float()、list() 等</li>
<li><strong>多写代码巩固知识</strong>：实践是最好的老师</li>
</ol>
<h3>课后练习</h3>
<ol>
<li>创建一个包含 5 个学生信息的列表。每个学生有姓名、年龄、成绩</li>
<li>计算平均分、最高分、最低分</li>
<li>筛选出成绩大于 80 的学生</li>
<li>将学生按成绩排序</li>
</ol>
<hr>
<p><em>关注我们获取更多 Python 教程！下节课我们将学习 Python 运算符与表达式。</em></p>
<p><a href="https://www.dixunblog.cn/1566.html">Python 变量与数据类型完全指南 &#8211; 基础篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1566.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Java Stream API 最佳实践 &#8211; 实战篇</title>
		<link>https://www.dixunblog.cn/1530.html</link>
					<comments>https://www.dixunblog.cn/1530.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Fri, 03 Apr 2026 06:07:26 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1530.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Java 教程！Stream API 是 Java 8 引入的强大工具。让集合操作更简洁、更高效。</p>
<p>一、Stream 基础</p>
<p>1.1 什么是 Stream<br />
Stream 是数据元素的序列。支持聚合操作：<br />
<code class="language-java">import java.util.*;<br />
i...</p>
<p><a href="https://www.dixunblog.cn/1530.html">Java Stream API 最佳实践 &#8211; 实战篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-image">
<img decoding="async" src="https://cdn.hyclive.cn/dixunblog/2026/04/java_stream_api.jpg" alt="Java Stream API" /><figcaption>Java Stream API 操作流程示意图</figcaption></figure>
<p>欢迎来到今天的 Java 教程！Stream API 是 Java 8 引入的强大工具。让集合操作更简洁、更高效。</p>
<h2>一、Stream 基础</h2>
<h3>1.1 什么是 Stream</h3>
<p>Stream 是数据元素的序列。支持聚合操作：</p>
<pre><code class="language-java">import java.util.*;
import java.util.stream.*;

List&lt;String&gt; list = Arrays.asList("Java", "Python", "Go", "Rust");

// 创建 Stream
Stream&lt;String&gt; stream = list.stream();</code></pre>
<h3>1.2 Stream 特点</h3>
<ul>
<li><strong>不存储数据</strong>：只是数据源的视图</li>
<li><strong>不修改源数据</strong>：操作返回新 Stream</li>
<li><strong>惰性求值</strong>：中间操作延迟执行</li>
<li><strong>只能遍历一次</strong>：用完需要重新创建</li>
</ul>
<h2>二、创建 Stream</h2>
<h3>2.1 从集合创建</h3>
<pre><code class="language-java">List&lt;String&gt; list = Arrays.asList("a", "b", "c");

// 方式 1：stream()
list.stream();

// 方式 2：parallelStream()
list.parallelStream();</code></pre>
<h3>2.2 从数组创建</h3>
<pre><code class="language-java">int[] arr = {1, 2, 3, 4, 5};

// 方式 1：Arrays.stream()
IntStream stream = Arrays.stream(arr);

// 方式 2：Stream.of()
Stream&lt;Integer&gt; stream2 = Stream.of(1, 2, 3);</code></pre>
<h3>2.3 生成 Stream</h3>
<pre><code class="language-java">// 无限流（需要 limit）
Stream&lt;Double&gt; randoms = Stream.generate(Math::random);
randoms.limit(5).forEach(System.out::println);

// 迭代流
Stream.iterate(0, n -&gt; n + 2)
      .limit(5)
      .forEach(System.out::println);  // 0, 2, 4, 6, 8</code></pre>
<h2>三、中间操作</h2>
<h3>3.1 过滤（filter）</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5, 6);

// 筛选偶数
numbers.stream()
       .filter(n -&gt; n % 2 == 0)
       .forEach(System.out::println);  // 2, 4, 6</code></pre>
<h3>3.2 映射（map）</h3>
<pre><code class="language-java">List&lt;String&gt; words = Arrays.asList("hello", "world");

// 转大写
words.stream()
     .map(String::toUpperCase)
     .forEach(System.out::println);  // HELLO, WORLD

// 提取长度
words.stream()
     .map(String::length)
     .forEach(System.out::println);  // 5, 5</code></pre>
<h3>3.3 扁平化（flatMap）</h3>
<pre><code class="language-java">List&lt;List&lt;Integer&gt;&gt; nested = Arrays.asList(
    Arrays.asList(1, 2),
    Arrays.asList(3, 4),
    Arrays.asList(5, 6)
);

// 扁平化
nested.stream()
      .flatMap(List::stream)
      .forEach(System.out::println);  // 1, 2, 3, 4, 5, 6</code></pre>
<h3>3.4 去重（distinct）</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 2, 3, 3, 3);

numbers.stream()
       .distinct()
       .forEach(System.out::println);  // 1, 2, 3</code></pre>
<h3>3.5 排序（sorted）</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(5, 2, 8, 1, 9);

// 自然排序
numbers.stream()
       .sorted()
       .forEach(System.out::println);  // 1, 2, 5, 8, 9

// 自定义排序
numbers.stream()
       .sorted(Comparator.reverseOrder())
       .forEach(System.out::println);  // 9, 8, 5, 2, 1</code></pre>
<h3>3.6 限制（limit, skip）</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5);

// 取前 3 个
numbers.stream().limit(3)
       .forEach(System.out::println);  // 1, 2, 3

// 跳过前 2 个
numbers.stream().skip(2)
       .forEach(System.out::println);  // 3, 4, 5

// 组合使用
numbers.stream().skip(1).limit(3)
       .forEach(System.out::println);  // 2, 3, 4</code></pre>
<h2>四、终端操作</h2>
<h3>4.1 遍历（forEach）</h3>
<pre><code class="language-java">List&lt;String&gt; list = Arrays.asList("a", "b", "c");
list.stream().forEach(System.out::println);</code></pre>
<h3>4.2 收集（collect）</h3>
<pre><code class="language-java">List&lt;String&gt; list = Arrays.asList("Java", "Python", "Go");

// 收集到 List
List&lt;String&gt; result = list.stream()
    .filter(s -&gt; s.length() &gt; 3)
    .collect(Collectors.toList());

// 收集到 Set
Set&lt;String&gt; set = list.stream()
    .collect(Collectors.toSet());

// 收集到 String
String joined = list.stream()
    .collect(Collectors.joining(", "));  // "Java, Python, Go"</code></pre>
<h3>4.3 归约（reduce）</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5);

// 求和
int sum = numbers.stream()
    .reduce(0, (a, b) -&gt; a + b);  // 15

// 求最大值
Optional&lt;Integer&gt; max = numbers.stream()
    .reduce(Integer::max);  // 5

// 求乘积
int product = numbers.stream()
    .reduce(1, (a, b) -&gt; a * b);  // 120</code></pre>
<h3>4.4 匹配（anyMatch, allMatch, noneMatch）</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5);

// 是否有偶数
boolean hasEven = numbers.stream()
    .anyMatch(n -&gt; n % 2 == 0);  // true

// 是否都大于 0
boolean allPositive = numbers.stream()
    .allMatch(n -&gt; n &gt; 0);  // true

// 是否没有负数
boolean noNegative = numbers.stream()
    .noneMatch(n -&gt; n &lt; 0);  // true</code></pre>
<h3>4.5 查找（findAny, findFirst）</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5);

// 查找第一个偶数
Optional&lt;Integer&gt; firstEven = numbers.stream()
    .filter(n -&gt; n % 2 == 0)
    .findFirst();  // 2

// 查找任意元素（并行流有用）
Optional&lt;Integer&gt; any = numbers.stream()
    .findAny();</code></pre>
<h3>4.6 统计（count, min, max）</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5);

// 计数
long count = numbers.stream().count();  // 5

// 最小值
Optional&lt;Integer&gt; min = numbers.stream().min(Integer::compareTo);

// 最大值
Optional&lt;Integer&gt; max = numbers.stream().max(Integer::compareTo);</code></pre>
<h2>五、数值流</h2>
<h3>5.1 IntStream、LongStream、DoubleStream</h3>
<pre><code class="language-java">List&lt;Integer&gt; numbers = Arrays.asList(1, 2, 3, 4, 5);

// 转换为 IntStream
IntStream intStream = numbers.stream().mapToInt(Integer::intValue);

// 统计信息
IntSummaryStatistics stats = numbers.stream()
    .mapToInt(Integer::intValue)
    .summaryStatistics();

System.out.println("平均值：" + stats.getAverage());  // 3.0
System.out.println("总和：" + stats.getSum());        // 15
System.out.println("最大值：" + stats.getMax());      // 5
System.out.println("最小值：" + stats.getMin());      // 1</code></pre>
<h2>六、分组和分区</h2>
<h3>6.1 分组（groupingBy）</h3>
<pre><code class="language-java">class Person {
    String name;
    int age;
    String city;
    // 构造方法、getter 省略
}

List&lt;Person&gt; people = Arrays.asList(
    new Person("张三", 25, "北京"),
    new Person("李四", 30, "上海"),
    new Person("王五", 25, "北京")
);

// 按年龄分组
Map&lt;Integer, List&lt;Person&gt;&gt; byAge = people.stream()
    .collect(Collectors.groupingBy(Person::getAge));

// 按城市分组
Map&lt;String, List&lt;Person&gt;&gt; byCity = people.stream()
    .collect(Collectors.groupingBy(Person::getCity));</code></pre>
<h3>6.2 分区（partitioningBy）</h3>
<pre><code class="language-java">// 按是否成年分区
Map&lt;Boolean, List&lt;Person&gt;&gt; byAdult = people.stream()
    .collect(Collectors.partitioningBy(p -&gt; p.getAge() &gt;= 18));

// true 分区：所有成年人
// false 分区：所有未成年人</code></pre>
<h2>七、并行流</h2>
<pre><code class="language-java">List&lt;Integer&gt; numbers = IntStream.rangeClosed(1, 1000000)
    .boxed()
    .collect(Collectors.toList());

// 串行流
long start = System.currentTimeMillis();
numbers.stream()
    .mapToInt(Integer::intValue)
    .sum();
System.out.println("串行：" + (System.currentTimeMillis() - start));

// 并行流
start = System.currentTimeMillis();
numbers.parallelStream()
    .mapToInt(Integer::intValue)
    .sum();
System.out.println("并行：" + (System.currentTimeMillis() - start));
</code></pre>
<hr>
<p><em>关注我们获取更多 Java 教程和最佳实践！</em></p>
<p><a href="https://www.dixunblog.cn/1530.html">Java Stream API 最佳实践 &#8211; 实战篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1530.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>二叉树遍历算法详解 &#8211; 进阶篇</title>
		<link>https://www.dixunblog.cn/1529.html</link>
					<comments>https://www.dixunblog.cn/1529.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Fri, 03 Apr 2026 06:07:24 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1529.html</guid>

					<description><![CDATA[<p>欢迎来到今天的数据结构教程！二叉树遍历是算法面试的必考题，也是实际开发中的基础技能。</p>
<p>一、二叉树基础</p>
<p>1.1 树的定义<br />
二叉树是每个节点最多有两个子节点的树结构：<br />
<code class="language-c">struct TreeNode {<br />
    int val;<br />
    struct TreeNode ...</p>
<p><a href="https://www.dixunblog.cn/1529.html">二叉树遍历算法详解 &#8211; 进阶篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-image">
<img decoding="async" src="https://cdn.hyclive.cn/dixunblog/2026/04/binary_tree_traversal.jpg" alt="二叉树遍历算法" /><figcaption>二叉树三种遍历方式示意图</figcaption></figure>
<p>欢迎来到今天的数据结构教程！二叉树遍历是算法面试的必考题，也是实际开发中的基础技能。</p>
<h2>一、二叉树基础</h2>
<h3>1.1 树的定义</h3>
<p>二叉树是每个节点最多有两个子节点的树结构：</p>
<pre><code class="language-c">struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
};</code></pre>
<h3>1.2 创建节点</h3>
<pre><code class="language-c">struct TreeNode* createNode(int val) {
    struct TreeNode* node = (struct TreeNode*)malloc(sizeof(struct TreeNode));
    node-&gt;val = val;
    node-&gt;left = NULL;
    node-&gt;right = NULL;
    return node;
}</code></pre>
<h2>二、前序遍历（Preorder）</h2>
<h3>2.1 遍历顺序</h3>
<p><strong>根节点 → 左子树 → 右子树</strong></p>
<h3>2.2 递归实现</h3>
<pre><code class="language-c">void preorderRecursive(struct TreeNode* root) {
    if (root == NULL) return;
    
    printf("%d ", root-&gt;val);           // 访问根节点
    preorderRecursive(root-&gt;left);      // 遍历左子树
    preorderRecursive(root-&gt;right);     // 遍历右子树
}

// 示例：
//       1
//      / \
//     2   3
//    / \
//   4   5
// 输出：1 2 4 5 3</code></pre>
<h3>2.3 迭代实现（使用栈）</h3>
<pre><code class="language-c">#include &lt;stdlib.h&gt;

void preorderIterative(struct TreeNode* root) {
    if (root == NULL) return;
    
    struct TreeNode* stack[100];
    int top = -1;
    
    stack[++top] = root;
    
    while (top &gt;= 0) {
        struct TreeNode* node = stack[top--];
        printf("%d ", node-&gt;val);
        
        // 先压右子树。后压左子树（栈是 LIFO）
        if (node-&gt;right) stack[++top] = node-&gt;right;
        if (node-&gt;left) stack[++top] = node-&gt;left;
    }
}</code></pre>
<h2>三、中序遍历（Inorder）</h2>
<h3>3.1 遍历顺序</h3>
<p><strong>左子树 → 根节点 → 右子树</strong></p>
<h3>3.2 递归实现</h3>
<pre><code class="language-c">void inorderRecursive(struct TreeNode* root) {
    if (root == NULL) return;
    
    inorderRecursive(root-&gt;left);       // 遍历左子树
    printf("%d ", root-&gt;val);           // 访问根节点
    inorderRecursive(root-&gt;right);      // 遍历右子树
}

// 示例（同上树）：4 2 5 1 3
// 重要：二叉搜索树的中序遍历是有序序列！</code></pre>
<h3>3.3 迭代实现</h3>
<pre><code class="language-c">void inorderIterative(struct TreeNode* root) {
    struct TreeNode* stack[100];
    int top = -1;
    struct TreeNode* current = root;
    
    while (current != NULL || top &gt;= 0) {
        // 一直向左
        while (current != NULL) {
            stack[++top] = current;
            current = current-&gt;left;
        }
        
        current = stack[top--];
        printf("%d ", current-&gt;val);
        current = current-&gt;right;
    }
}</code></pre>
<h2>四、后序遍历（Postorder）</h2>
<h3>4.1 遍历顺序</h3>
<p><strong>左子树 → 右子树 → 根节点</strong></p>
<h3>4.2 递归实现</h3>
<pre><code class="language-c">void postorderRecursive(struct TreeNode* root) {
    if (root == NULL) return;
    
    postorderRecursive(root-&gt;left);     // 遍历左子树
    postorderRecursive(root-&gt;right);    // 遍历右子树
    printf("%d ", root-&gt;val);           // 访问根节点
}

// 示例（同上树）：4 5 2 3 1
// 应用：计算树的高度、释放树的内存</code></pre>
<h3>4.3 迭代实现（双栈法）</h3>
<pre><code class="language-c">void postorderIterative(struct TreeNode* root) {
    if (root == NULL) return;
    
    struct TreeNode* stack1[100];
    struct TreeNode* stack2[100];
    int top1 = -1, top2 = -1;
    
    stack1[++top1] = root;
    
    // 第一个栈：根→右→左
    while (top1 &gt;= 0) {
        struct TreeNode* node = stack1[top1--];
        stack2[++top2] = node;
        
        if (node-&gt;left) stack1[++top1] = node-&gt;left;
        if (node-&gt;right) stack1[++top1] = node-&gt;right;
    }
    
    // 第二个栈：左→右→根
    while (top2 &gt;= 0) {
        printf("%d ", stack2[top2--]-&gt;val);
    }
}</code></pre>
<h2>五、层序遍历（Level Order）</h2>
<h3>5.1 遍历顺序</h3>
<p><strong>从上到下。从左到右（使用队列）</strong></p>
<h3>5.2 实现代码</h3>
<pre><code class="language-c">void levelOrder(struct TreeNode* root) {
    if (root == NULL) return;
    
    struct TreeNode* queue[100];
    int front = 0, rear = 0;
    
    queue[rear++] = root;
    
    while (front &lt; rear) {
        int levelSize = rear - front;
        
        for (int i = 0; i &lt; levelSize; i++) {
            struct TreeNode* node = queue[front++];
            printf("%d ", node-&gt;val);
            
            if (node-&gt;left) queue[rear++] = node-&gt;left;
            if (node-&gt;right) queue[rear++] = node-&gt;right;
        }
        printf("\n");  // 每层换行
    }
}

// 示例（同上树）：
// 第 1 层：1
// 第 2 层：2 3
// 第 3 层：4 5</code></pre>
<h2>六、遍历应用</h2>
<h3>6.1 计算树的高度</h3>
<pre><code class="language-c">int maxDepth(struct TreeNode* root) {
    if (root == NULL) return 0;
    
    int leftHeight = maxDepth(root-&gt;left);
    int rightHeight = maxDepth(root-&gt;right);
    
    return (leftHeight &gt; rightHeight ? leftHeight : rightHeight) + 1;
}</code></pre>
<h3>6.2 查找节点</h3>
<pre><code class="language-c">struct TreeNode* search(struct TreeNode* root, int val) {
    if (root == NULL) return NULL;
    if (root-&gt;val == val) return root;
    
    struct TreeNode* leftResult = search(root-&gt;left, val);
    if (leftResult != NULL) return leftResult;
    
    return search(root-&gt;right, val);
}</code></pre>
<h3>6.3 释放树的内存</h3>
<pre><code class="language-c">void freeTree(struct TreeNode* root) {
    if (root == NULL) return;
    
    freeTree(root-&gt;left);
    freeTree(root-&gt;right);
    free(root);  // 后序遍历释放
}</code></pre>
<h2>七、复杂度分析</h2>
<pre><code class="language-text">遍历方式    时间复杂度    空间复杂度
前序        O(n)         O(h)
中序        O(n)         O(h)
后序        O(n)         O(h)
层序        O(n)         O(w)

n = 节点数。h = 树高。w = 最大宽度</code></pre>
<h2>八、总结</h2>
<p>二叉树遍历是数据结构的基础：</p>
<ol>
<li><strong>前序</strong>：复制树、序列化</li>
<li><strong>中序</strong>：二叉搜索树排序</li>
<li><strong>后序</strong>：释放内存、计算高度</li>
<li><strong>层序</strong>：BFS、层次处理</li>
</ol>
<hr>
<p><em>关注我们获取更多数据结构教程！</em></p>
<p><a href="https://www.dixunblog.cn/1529.html">二叉树遍历算法详解 &#8211; 进阶篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1529.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>C 语言结构体与指针实战 &#8211; 基础篇</title>
		<link>https://www.dixunblog.cn/1528.html</link>
					<comments>https://www.dixunblog.cn/1528.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Fri, 03 Apr 2026 06:07:23 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[代码教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1528.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 C 语言教程！结构体和指针是 C 语言的核心，掌握它们对理解内存管理至关重要。</p>
<p>一、结构体基础</p>
<p>1.1 结构体定义<br />
结构体允许我们将不同类型的数据组合在一起：<br />
<code class="language-c">#include &#60;stdio.h&#62;<br />
#include &#60;string....</p>
<p><a href="https://www.dixunblog.cn/1528.html">C 语言结构体与指针实战 &#8211; 基础篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-image">
<img decoding="async" src="https://cdn.hyclive.cn/dixunblog/2026/04/c_pointer_tutorial.jpg" alt="C 语言结构体与指针" /><figcaption>C 语言结构体与指针示意图</figcaption></figure>
<p>欢迎来到今天的 C 语言教程！结构体和指针是 C 语言的核心，掌握它们对理解内存管理至关重要。</p>
<h2>一、结构体基础</h2>
<h3>1.1 结构体定义</h3>
<p>结构体允许我们将不同类型的数据组合在一起：</p>
<pre><code class="language-c">#include &lt;stdio.h&gt;
#include &lt;string.h&gt;

// 定义学生结构体
struct Student {
    char name[50];
    int age;
    float score;
};

int main() {
    // 创建结构体变量
    struct Student stu1;
    strcpy(stu1.name, "张三");
    stu1.age = 20;
    stu1.score = 95.5;
    
    printf("姓名：%s, 年龄：%d, 成绩：%.1f\n", 
           stu1.name, stu1.age, stu1.score);
    return 0;
}</code></pre>
<h3>1.2 结构体数组</h3>
<pre><code class="language-c">struct Student class[3] = {
    {"张三", 20, 95.5},
    {"李四", 21, 88.0},
    {"王五", 19, 92.5}
};

// 遍历结构体数组
for (int i = 0; i &lt; 3; i++) {
    printf("%s: %.1f 分\n", class[i].name, class[i].score);
}</code></pre>
<h2>二、指针基础</h2>
<h3>2.1 指针定义</h3>
<p>指针存储变量的内存地址：</p>
<pre><code class="language-c">int num = 42;
int *ptr = &amp;num;  // ptr 指向 num 的地址

printf("num 的值：%d\n", num);
printf("num 的地址：%p\n", (void*)&amp;num);
printf("ptr 的值：%p\n", (void*)ptr);
printf("ptr 指向的值：%d\n", *ptr);  // 解引用</code></pre>
<h3>2.2 指针运算</h3>
<pre><code class="language-c">int arr[] = {10, 20, 30, 40, 50};
int *p = arr;  // p 指向数组首元素

printf("%d\n", *p);      // 10
printf("%d\n", *(p+1));  // 20
printf("%d\n", *(p+2));  // 30

// 指针遍历数组
for (int i = 0; i &lt; 5; i++) {
    printf("%d ", *(p+i));
}</code></pre>
<h2>三、结构体指针</h2>
<h3>3.1 指向结构体的指针</h3>
<pre><code class="language-c">struct Student stu = {"张三", 20, 95.5};
struct Student *ptr = &amp;stu;

// 访问结构体成员（两种方式）
printf("%s\n", ptr-&gt;name);  // 推荐：使用箭头运算符
printf("%d\n", (*ptr).age); // 等价。但不常用</code></pre>
<h3>3.2 结构体指针数组</h3>
<pre><code class="language-c">struct Student s1 = {"张三", 20, 95.5};
struct Student s2 = {"李四", 21, 88.0};
struct Student s3 = {"王五", 19, 92.5};

// 指针数组（存储地址。节省内存）
struct Student *students[] = {&amp;s1, &amp;s2, &amp;s3};

for (int i = 0; i &lt; 3; i++) {
    printf("%s: %d 岁\n", students[i]-&gt;name, students[i]-&gt;age);
}</code></pre>
<h2>四、动态内存分配</h2>
<h3>4.1 malloc 和 free</h3>
<pre><code class="language-c">#include &lt;stdlib.h&gt;

// 动态分配结构体内存
struct Student *createStudent(char *name, int age, float score) {
    struct Student *stu = (struct Student*)malloc(sizeof(struct Student));
    strcpy(stu-&gt;name, name);
    stu-&gt;age = age;
    stu-&gt;score = score;
    return stu;
}

int main() {
    struct Student *stu = createStudent("赵六", 22, 90.0);
    printf("%s: %.1f 分\n", stu-&gt;name, stu-&gt;score);
    
    // 释放内存（重要！）
    free(stu);
    return 0;
}</code></pre>
<h3>4.2 动态结构体数组</h3>
<pre><code class="language-c">int n = 5;
struct Student *class = (struct Student*)malloc(n * sizeof(struct Student));

// 使用
for (int i = 0; i &lt; n; i++) {
    sprintf(class[i].name, "学生%d", i+1);
    class[i].age = 20 + i;
}

// 释放
free(class);</code></pre>
<h2>五、链表实现</h2>
<h3>5.1 链表节点定义</h3>
<pre><code class="language-c">struct Node {
    int data;
    struct Node *next;
};

// 创建新节点
struct Node* createNode(int data) {
    struct Node *newNode = (struct Node*)malloc(sizeof(struct Node));
    newNode-&gt;data = data;
    newNode-&gt;next = NULL;
    return newNode;
}</code></pre>
<h3>5.2 插入节点</h3>
<pre><code class="language-c">void insertAtHead(struct Node **head, int data) {
    struct Node *newNode = createNode(data);
    newNode-&gt;next = *head;
    *head = newNode;
}

// 使用
struct Node *head = NULL;
insertAtHead(&amp;head, 30);
insertAtHead(&amp;head, 20);
insertAtHead(&amp;head, 10);
// 链表：10 -&gt; 20 -&gt; 30</code></pre>
<h3>5.3 遍历链表</h3>
<pre><code class="language-c">void printList(struct Node *head) {
    struct Node *current = head;
    while (current != NULL) {
        printf("%d -&gt; ", current-&gt;data);
        current = current-&gt;next;
    }
    printf("NULL\n");
}</code></pre>
<h2>六、常见错误</h2>
<h3>6.1 野指针</h3>
<pre><code class="language-c">// 错误：未初始化的指针
int *ptr;
*ptr = 42;  // 崩溃！

// 正确：初始化或分配内存
int num = 42;
int *ptr = &amp;num;
*ptr = 42;  // OK</code></pre>
<h3>6.2 内存泄漏</h3>
<pre><code class="language-c">// 错误：分配后未释放
struct Student *stu = malloc(sizeof(struct Student));
// ... 使用
// 忘记 free(stu) - 内存泄漏！

// 正确：成对使用 malloc/free
struct Student *stu = malloc(sizeof(struct Student));
// ... 使用
free(stu);  // 释放内存</code></pre>
<h2>七、总结</h2>
<p>结构体和指针是 C 语言的精髓：</p>
<ol>
<li>结构体用于组织相关数据</li>
<li>指针用于直接操作内存</li>
<li>结构体指针结合两者优势</li>
<li>动态内存分配需要手动管理</li>
<li>链表是指针的经典应用</li>
</ol>
<hr>
<p><em>关注我们获取更多 C 语言教程！</em></p>
<p><a href="https://www.dixunblog.cn/1528.html">C 语言结构体与指针实战 &#8211; 基础篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1528.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>macOS 隐藏功能与效率工具 &#8211; 实战篇</title>
		<link>https://www.dixunblog.cn/1483.html</link>
					<comments>https://www.dixunblog.cn/1483.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Wed, 01 Apr 2026 02:06:09 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[macOS 教程]]></category>
		<category><![CDATA[代码教程]]></category>
		<category><![CDATA[系统教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1483.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 macOS 效率教程！挖掘那些鲜为人知的隐藏功能，让你的 Mac 更好用。</p>
<p>一、系统隐藏功能</p>
<p>1.1 快捷键进阶</p>
<p>除了基础的 Cmd+C/V。这些快捷键更实用：</p>
<p><strong>Cmd + Shift + 3</strong>：全屏截图<br />
<strong>Cmd + Shift + 4&#60;/str...</p>
<p><a href="https://www.dixunblog.cn/1483.html">macOS 隐藏功能与效率工具 &#8211; 实战篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 macOS 效率教程！挖掘那些鲜为人知的隐藏功能，让你的 Mac 更好用。</p>
<h2>一、系统隐藏功能</h2>
<h3>1.1 快捷键进阶</h3>
<p>除了基础的 Cmd+C/V。这些快捷键更实用：</p>
<ul>
<li><strong>Cmd + Shift + 3</strong>：全屏截图</li>
<li><strong>Cmd + Shift + 4</strong>：区域截图</li>
<li><strong>Cmd + Shift + 5</strong>：截图/录屏工具</li>
<li><strong>Cmd + Space</strong>：聚焦搜索（Spotlight）</li>
<li><strong>Cmd + Tab</strong>：切换应用</li>
<li><strong>Cmd + `</strong>：同一应用的不同窗口切换</li>
<li><strong>Cmd + W</strong>：关闭当前窗口</li>
<li><strong>Cmd + Q</strong>：退出应用</li>
<li><strong>Cmd + H</strong>：隐藏当前应用窗口</li>
<li><strong>Cmd + M</strong>：最小化到 Dock</li>
</ul>
<h3>1.2 触控板手势</h3>
<p>系统设置 &gt; 触控板：</p>
<ul>
<li><strong>双指滑动</strong>：滚动页面</li>
<li><strong>双指捏合</strong>：缩放</li>
<li><strong>三指滑动</strong>：切换全屏幕应用</li>
<li><strong>四指滑动</strong>：显示桌面/调度中心</li>
<li><strong>三指拖移</strong>：无需按住即可拖移（需启用）</li>
</ul>
<h3>1.3 快速查看（Quick Look）</h3>
<p>选中文件后按<strong>空格键</strong>：</p>
<ul>
<li>预览文档、图片、视频</li>
<li>播放音频文件</li>
<li>查看 PDF 并标注</li>
<li>按 Cmd + Y 全屏预览</li>
</ul>
<h2>二、Finder 效率技巧</h2>
<h3>2.1 隐藏菜单</h3>
<p>在 Finder 中：</p>
<ul>
<li><strong>查看 &gt; 显示选项</strong>：自定义显示方式</li>
<li><strong>前往 &gt; 前往文件夹</strong>（Cmd + Shift + G）：输入路径直达</li>
<li><strong>按住 Option 键</strong>：显示&#8221;资源库&#8221;文件夹</li>
</ul>
<h3>2.2 标签和智能文件夹</h3>
<p><strong>标签：</strong></p>
<ol>
<li>右键文件 &gt; 标签</li>
<li>用颜色标记不同类型文件</li>
<li>侧边栏点击标签快速筛选</li>
</ol>
<p><strong>智能文件夹：</strong></p>
<ol>
<li>文件 &gt; 新建智能文件夹</li>
<li>设置条件（如：类型=PDF。修改日期=本周）</li>
<li>自动聚合符合条件的文件</li>
</ol>
<h3>2.3 分屏浏览</h3>
<ul>
<li><strong>Cmd + N</strong>：打开新 Finder 窗口</li>
<li>拖动文件时按<strong>Option</strong>：复制而非移动</li>
<li>拖动到 Dock 的应用图标：用该应用打开</li>
</ul>
<h2>三、聚焦搜索（Spotlight）</h2>
<h3>3.1 基础用法</h3>
<p><strong>Cmd + Space</strong> 打开聚焦搜索：</p>
<ul>
<li>搜索文件和文件夹</li>
<li>启动应用</li>
<li>计算数学表达式（如：123*456）</li>
<li>查询天气（如：北京天气）</li>
<li>单位换算（如：100 USD to CNY）</li>
<li>定义单词（如：define awesome）</li>
</ul>
<h3>3.2 高级技巧</h3>
<ul>
<li><strong>kind:pdf</strong>：只搜索 PDF 文件</li>
<li><strong>date:yesterday</strong>：搜索昨天的文件</li>
<li><strong>size:large</strong>：搜索大文件</li>
</ul>
<h2>四、自动操作（Automator）</h2>
<h3>4.1 创建快速操作</h3>
<ol>
<li>打开&#8221;自动操作&#8221;应用</li>
<li>选择&#8221;快速操作&#8221;</li>
<li>拖入需要的动作（如：调整图片大小）</li>
<li>保存后在 Finder 右键菜单使用</li>
</ol>
<h3>4.2 实用自动化</h3>
<ul>
<li>批量重命名文件</li>
<li>图片格式转换</li>
<li>PDF 合并</li>
<li>提取音频</li>
</ul>
<h2>五、终端技巧</h2>
<h3>5.1 常用命令</h3>
<pre><code class="language-bash"># macOS 特有命令
open .                    # 用 Finder 打开当前目录
open -a "App Name"        # 打开应用
say "Hello"               # 文本转语音
screencapture -i screen.png  # 截图

# 与 Linux 通用的命令
ls, cd, cp, mv, rm, grep 等</code></pre>
<h3>5.2 Homebrew 包管理</h3>
<pre><code class="language-bash"># 安装 Homebrew（如果还没装）
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 常用命令
brew install package      # 安装包
brew uninstall package    # 卸载
brew update               # 更新
brew upgrade              # 升级已安装的包
brew search keyword       # 搜索
brew list                 # 列出已安装的包</code></pre>
<h2>六、推荐效率工具</h2>
<h3>6.1 系统增强</h3>
<ul>
<li><strong>Raycast</strong>：Spotlight 替代品。功能更强大（免费）</li>
<li><strong>Alfred</strong>：老牌效率工具（基础版免费）</li>
<li><strong>BetterTouchTool</strong>：自定义手势和快捷键</li>
<li><strong>Keyboard Maestro</strong>：强大的自动化宏工具</li>
</ul>
<h3>6.2 窗口管理</h3>
<ul>
<li><strong>Rectangle</strong>：免费窗口管理（类似 Windows 贴靠）</li>
<li><strong>Magnet</strong>：付费窗口管理（App Store）</li>
<li><strong>Moom</strong>：高级窗口管理</li>
</ul>
<h3>6.3 剪贴板</h3>
<ul>
<li><strong>Maccy</strong>：轻量剪贴板历史（开源免费）</li>
<li><strong>Paste</strong>：美观的剪贴板管理（订阅制）</li>
<li><strong>CopyClip</strong>：简单的剪贴板历史（免费）</li>
</ul>
<h3>6.4 其他必备</h3>
<ul>
<li><strong>The Unarchiver</strong>：解压各种格式（免费）</li>
<li><strong>Keka</strong>：压缩工具（免费）</li>
<li><strong>IINA</strong>：现代视频播放器（免费开源）</li>
<li><strong>AppCleaner</strong>：彻底卸载应用（免费）</li>
</ul>
<h2>七、系统优化</h2>
<h3>7.1 启动项管理</h3>
<p>系统设置 &gt; 通用 &gt; 登录项：</p>
<ul>
<li>禁用不必要的登录项</li>
<li>移除后台应用</li>
</ul>
<h3>7.2 存储空间管理</h3>
<p>系统设置 &gt; 通用 &gt; 存储空间：</p>
<ul>
<li>启用&#8221;优化存储&#8221;</li>
<li>自动清空回收站（30 天后）</li>
<li>iCloud 照片优化</li>
</ul>
<h3>7.3 电池优化</h3>
<ul>
<li>系统设置 &gt; 电池 &gt; 电池健康 &gt; 优化电池充电</li>
<li>避免长时间高温使用</li>
<li>定期校准电池（每月一次完全充放电）</li>
</ul>
<h2>八、总结</h2>
<p>macOS 有很多隐藏的效率功能。建议：</p>
<ol>
<li>熟记常用快捷键</li>
<li>善用聚焦搜索</li>
<li>安装 Raycast 和 Rectangle</li>
<li>探索自动操作的可能性</li>
</ol>
<hr>
<p><em>关注我们获取更多 macOS 使用教程和效率技巧！</em></p>
<p><a href="https://www.dixunblog.cn/1483.html">macOS 隐藏功能与效率工具 &#8211; 实战篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1483.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Linux 常用命令速查手册 &#8211; 进阶篇</title>
		<link>https://www.dixunblog.cn/1482.html</link>
					<comments>https://www.dixunblog.cn/1482.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Wed, 01 Apr 2026 02:06:08 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Linux 教程]]></category>
		<category><![CDATA[代码教程]]></category>
		<category><![CDATA[系统教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1482.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Linux 命令速查手册！这是每个 Linux 用户都应该收藏的参考指南。</p>
<p>一、文件和目录操作</p>
<p>1.1 目录导航</p>
<p><code class="language-bash"># 查看当前目录<br />
pwd</p>
<p># 切换目录<br />
cd /path/to/dir<br />
cd ..          # 返回上级<br />
cd ~ ...</p>
<p><a href="https://www.dixunblog.cn/1482.html">Linux 常用命令速查手册 &#8211; 进阶篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 Linux 命令速查手册！这是每个 Linux 用户都应该收藏的参考指南。</p>
<h2>一、文件和目录操作</h2>
<h3>1.1 目录导航</h3>
<pre><code class="language-bash"># 查看当前目录
pwd

# 切换目录
cd /path/to/dir
cd ..          # 返回上级
cd ~           # 回到家目录
cd -           # 返回上一个目录

# 列出目录内容
ls             # 简单列表
ls -l          # 详细信息
ls -la         # 包含隐藏文件
ls -lh         # 人类可读的文件大小
ls -lt         # 按时间排序</code></pre>
<h3>1.2 文件操作</h3>
<pre><code class="language-bash"># 创建文件
touch filename.txt
echo "内容" &gt; filename.txt

# 创建目录
mkdir dirname
mkdir -p parent/child/grandchild  # 递归创建

# 复制文件/目录
cp file1 file2
cp -r dir1 dir2  # 复制目录

# 移动/重命名
mv oldname newname
mv file /path/to/dir/

# 删除
rm file
rm -r dirname    # 删除目录（危险！）
rm -rf dirname   # 强制删除（非常危险！）</code></pre>
<h3>1.3 查看文件内容</h3>
<pre><code class="language-bash"># 查看整个文件
cat filename

# 分页查看（适合大文件）
less filename
# 操作：空格翻页。b 上一页。q 退出。/搜索

# 查看前/后 N 行
head -n 20 filename
tail -n 20 filename

# 实时查看日志
tail -f /var/log/syslog</code></pre>
<h2>二、文件权限管理</h2>
<h3>2.1 查看权限</h3>
<pre><code class="language-bash">ls -l
# 输出：-rwxr-xr-x 1 user group 4096 Jan 1 12:00 filename
#       ^^^^ ^^^^ ^^^
#       类型  用户  组   其他</code></pre>
<h3>2.2 修改权限</h3>
<pre><code class="language-bash"># 符号模式
chmod +x script.sh        # 添加执行权限
chmod u+x file            # 给所有者添加执行权限
chmod go-w file           # 移除组和其他的写权限

# 数字模式
chmod 755 script.sh       # rwxr-xr-x
chmod 644 file.txt        # rw-r--r--
chmod 600 secret.key      # rw-------

# 修改所有者
chown user:group filename
chown -R user:group dirname  # 递归修改</code></pre>
<h2>三、进程管理</h2>
<h3>3.1 查看进程</h3>
<pre><code class="language-bash"># 查看当前终端进程
ps

# 查看所有进程
ps aux
# A: 所有用户。u: 用户格式。x: 包含无终端进程

# 动态查看（类似任务管理器）
top
htop  # 更友好的界面（需安装）

# 查看特定进程
ps aux | grep nginx
pgrep nginx</code></pre>
<h3>3.2 管理进程</h3>
<pre><code class="language-bash"># 终止进程
kill PID
kill -9 PID      # 强制终止
killall nginx    # 按进程名终止
pkill nginx      # 按模式终止

# 后台运行
command &amp;        # 后台运行
nohup command &amp;  # 退出终端后继续运行</code></pre>
<h2>四、网络命令</h2>
<h3>4.1 网络诊断</h3>
<pre><code class="language-bash"># 检查连接
ping google.com
ping -c 4 google.com  # 只 ping 4 次

# 追踪路由
traceroute google.com
tracepath google.com  # 无需 root

# 查看端口占用
netstat -tulpn
ss -tulpn  # 更现代的版本

# DNS 查询
nslookup google.com
dig google.com</code></pre>
<h3>4.2 网络配置</h3>
<pre><code class="language-bash"># 查看 IP 地址
ip addr
ifconfig  # 旧命令（需安装 net-tools）

# 查看路由
ip route
route -n

# 查看 DNS
cat /etc/resolv.conf

# 测试端口连接
telnet host port
nc -zv host port  # netcat</code></pre>
<h2>五、磁盘管理</h2>
<h3>5.1 查看磁盘空间</h3>
<pre><code class="language-bash"># 查看文件系统使用情况
df -h
# -h: 人类可读格式（GB/MB）

# 查看目录大小
du -sh /path/to/dir
du -ah --max-depth=1 /path  # 查看一级子目录</code></pre>
<h3>5.2 查找大文件</h3>
<pre><code class="language-bash"># 查找大于 100M 的文件
find / -type f -size +100M

# 按大小排序查找最大的 10 个文件
find / -type f -exec du -h {} + | sort -rh | head -10</code></pre>
<h2>六、文本处理</h2>
<h3>6.1 搜索内容</h3>
<pre><code class="language-bash"># 在文件中搜索
grep "pattern" filename
grep -r "pattern" /path  # 递归搜索
grep -i "pattern"        # 忽略大小写
grep -v "pattern"        # 反向匹配
grep -n "pattern"        # 显示行号</code></pre>
<h3>6.2 文本编辑</h3>
<pre><code class="language-bash"># sed 替换（流编辑器）
sed 's/old/new/g' file         # 替换所有
sed -i 's/old/new/g' file      # 直接修改文件
sed -i '3d' file               # 删除第 3 行

# awk 处理（强大的文本分析）
awk '{print $1}' file          # 打印第一列
awk -F: '{print $1}' /etc/passwd  # 指定分隔符</code></pre>
<h3>6.3 重定向和管道</h3>
<pre><code class="language-bash"># 重定向
command &gt; file      # 覆盖输出
command &gt;&gt; file     # 追加输出
command 2&gt;&amp;1        # 重定向错误输出

# 管道（将前一个命令的输出作为后一个的输入）
ps aux | grep nginx
cat file.txt | wc -l
ls -la | grep "^d"</code></pre>
<h2>七、压缩和解压</h2>
<pre><code class="language-bash"># tar 归档
tar -cvf archive.tar file1 file2      # 创建
tar -xvf archive.tar                   # 解压
tar -czvf archive.tar.gz dir/         # gzip 压缩
tar -xzvf archive.tar.gz              # gzip 解压
tar -cjvf archive.tar.bz2 dir/        # bzip2 压缩
tar -xjvf archive.tar.bz2             # bzip2 解压

# zip/unzip
zip -r archive.zip dir/
unzip archive.zip

# gzip（只能压缩单个文件）
gzip file
gunzip file.gz</code></pre>
<h2>八、系统信息</h2>
<pre><code class="language-bash"># 系统信息
uname -a              # 内核信息
cat /etc/os-release   # 发行版信息
hostname              # 主机名

# CPU 信息
lscpu
cat /proc/cpuinfo

# 内存信息
free -h
cat /proc/meminfo

# 运行时间
uptime</code></pre>
<h2>九、软件包管理</h2>
<h3>9.1 Debian/Ubuntu</h3>
<pre><code class="language-bash"># apt 包管理
sudo apt update
sudo apt upgrade
sudo apt install package_name
sudo apt remove package_name
sudo apt search keyword
sudo apt show package_name</code></pre>
<h3>9.2 RHEL/CentOS</h3>
<pre><code class="language-bash"># yum/dnf 包管理
sudo yum update
sudo yum install package_name
sudo yum remove package_name</code></pre>
<h2>十、实用技巧</h2>
<h3>10.1 命令历史</h3>
<pre><code class="language-bash">history           # 查看历史命令
!123             # 执行第 123 条历史命令
!!               # 执行上一条命令
!$               # 上一条命令的最后一个参数
Ctrl + R         # 搜索历史命令</code></pre>
<h3>10.2 命令别名</h3>
<pre><code class="language-bash"># 临时别名
alias ll='ls -la'
alias gs='git status'

# 永久别名（添加到 ~/.bashrc）
echo "alias ll='ls -la'" &gt;&gt; ~/.bashrc
source ~/.bashrc</code></pre>
<h2>十一、总结</h2>
<p>Linux 命令是系统管理的核心技能。建议：</p>
<ol>
<li>每天练习 5-10 个命令</li>
<li>使用 <code>man command</code> 查看帮助</li>
<li>善用 Tab 键自动补全</li>
<li>将常用命令保存为脚本</li>
</ol>
<hr>
<p><em>关注我们获取更多 Linux 教程和系统管理技巧！</em></p>
<p><a href="https://www.dixunblog.cn/1482.html">Linux 常用命令速查手册 &#8211; 进阶篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1482.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Windows 11 必学快捷键与效率技巧 &#8211; 基础篇</title>
		<link>https://www.dixunblog.cn/1481.html</link>
					<comments>https://www.dixunblog.cn/1481.html#respond</comments>
		
		<dc:creator><![CDATA[小编]]></dc:creator>
		<pubDate>Wed, 01 Apr 2026 02:06:06 +0000</pubDate>
				<category><![CDATA[技术教程]]></category>
		<category><![CDATA[Windows 教程]]></category>
		<category><![CDATA[代码教程]]></category>
		<category><![CDATA[系统教程]]></category>
		<guid isPermaLink="false">https://www.dixunblog.cn/1481.html</guid>

					<description><![CDATA[<p>欢迎来到今天的 Windows 效率教程！掌握这些快捷键和技巧，让你的工作效率翻倍。</p>
<p>一、基础快捷键</p>
<p>1.1 系统级快捷键</p>
<p>这些快捷键在所有场景都适用：</p>
<p><strong>Win + D</strong>：显示桌面（最小化所有窗口）<br />
<strong>Win + E</strong>：打开文件资源管理器<br />
&#60;str...</p>
<p><a href="https://www.dixunblog.cn/1481.html">Windows 11 必学快捷键与效率技巧 &#8211; 基础篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>欢迎来到今天的 Windows 效率教程！掌握这些快捷键和技巧，让你的工作效率翻倍。</p>
<h2>一、基础快捷键</h2>
<h3>1.1 系统级快捷键</h3>
<p>这些快捷键在所有场景都适用：</p>
<ul>
<li><strong>Win + D</strong>：显示桌面（最小化所有窗口）</li>
<li><strong>Win + E</strong>：打开文件资源管理器</li>
<li><strong>Win + L</strong>：锁定电脑（离开座位必备）</li>
<li><strong>Win + V</strong>：打开剪贴板历史（需先启用）</li>
<li><strong>Win + .</strong>：打开表情符号面板</li>
<li><strong>Win + Shift + S</strong>：截图（区域截图）</li>
<li><strong>Alt + Tab</strong>：切换应用</li>
<li><strong>Win + Tab</strong>：任务视图（虚拟桌面）</li>
</ul>
<h3>1.2 窗口管理快捷键</h3>
<ul>
<li><strong>Win + ←/→/↑/↓</strong>：窗口贴靠（左/右/最大化/还原）</li>
<li><strong>Win + Home</strong>：最小化除当前窗口外的所有窗口</li>
<li><strong>Alt + F4</strong>：关闭当前窗口</li>
<li><strong>Win + M</strong>：最小化所有窗口</li>
</ul>
<h2>二、进阶效率技巧</h2>
<h3>2.1 虚拟桌面</h3>
<p>虚拟桌面可以帮助你分隔工作和娱乐：</p>
<ul>
<li><strong>Win + Ctrl + D</strong>：创建新虚拟桌面</li>
<li><strong>Win + Ctrl + ←/→</strong>：切换虚拟桌面</li>
<li><strong>Win + Ctrl + F4</strong>：关闭当前虚拟桌面</li>
</ul>
<h3>2.2 电源用户菜单</h3>
<p><strong>Win + X</strong> 打开电源用户菜单。快速访问：</p>
<ul>
<li>设备管理器</li>
<li>磁盘管理</li>
<li>Windows 终端（管理员）</li>
<li>任务管理器</li>
<li>设置</li>
</ul>
<h3>2.3 文件资源管理器技巧</h3>
<ul>
<li><strong>Ctrl + Shift + N</strong>：新建文件夹</li>
<li><strong>Alt + D</strong>：选中地址栏</li>
<li><strong>Ctrl + F</strong>：搜索</li>
<li><strong>Alt + Enter</strong>：查看属性</li>
<li><strong>Ctrl + 鼠标滚轮</strong>：切换图标大小</li>
</ul>
<h2>三、Windows 11 专属功能</h2>
<h3>3.1 贴靠布局</h3>
<p>Windows 11 的贴靠布局更强大：</p>
<ol>
<li>将窗口拖到屏幕顶部中间</li>
<li>选择喜欢的布局（2/3/4 分屏）</li>
<li>为每个区域选择应用</li>
</ol>
<h3>3.2 专注会话</h3>
<p>在&#8221;设置 &gt; 系统 &gt; 专注会话&#8221;中启用。可以：</p>
<ul>
<li>设定专注时间（25/45/60 分钟）</li>
<li>屏蔽通知</li>
<li>播放白噪音</li>
</ul>
<h3>3.3 小组件</h3>
<p><strong>Win + W</strong> 打开小组件面板：</p>
<ul>
<li>天气、新闻、日历</li>
<li>待办事项</li>
<li>股票、体育比分</li>
</ul>
<h2>四、实用工具推荐</h2>
<h3>4.1 微软官方工具</h3>
<ul>
<li><strong>PowerToys</strong>：微软官方效率工具集（强烈推荐）
<ul>
<li>FancyZones：高级窗口布局</li>
<li>PowerToys Run：快速启动器</li>
<li>图像调整器：批量调整图片大小</li>
<li>键盘管理器：自定义快捷键</li>
</ul>
</li>
<li><strong>Windows 终端</strong>：现代化命令行工具</li>
</ul>
<h3>4.2 第三方工具</h3>
<ul>
<li><strong>Everything</strong>：极速文件搜索</li>
<li><strong>Geek Uninstaller</strong>：彻底卸载软件</li>
<li><strong>WizTree</strong>：磁盘空间分析</li>
<li><strong>Snipaste</strong>：高级截图工具</li>
</ul>
<h2>五、系统优化建议</h2>
<h3>5.1 启动项管理</h3>
<p>任务管理器 &gt; 启动。禁用不必要的启动项：</p>
<ul>
<li>第三方杀毒软件（有 Windows Defender 就够了）</li>
<li>云盘同步（需要时再开）</li>
<li>聊天软件（手动启动即可）</li>
</ul>
<h3>5.2 存储感知</h3>
<p>设置 &gt; 系统 &gt; 存储 &gt; 存储感知。启用后自动：</p>
<ul>
<li>删除临时文件</li>
<li>清空回收站（30 天后）</li>
<li>清理旧版本 Windows</li>
</ul>
<h3>5.3 视觉效果优化</h3>
<p>系统 &gt; 关于 &gt; 高级系统设置 &gt; 性能：</p>
<ul>
<li>老电脑：选择&#8221;调整为最佳性能&#8221;</li>
<li>新电脑：保留&#8221;平滑屏幕字体边缘&#8221;即可</li>
</ul>
<h2>六、常见问题解决</h2>
<h3>6.1 系统卡顿</h3>
<ol>
<li>任务管理器查看资源占用</li>
<li>结束异常进程</li>
<li>重启 Windows 资源管理器</li>
<li>检查磁盘空间（保持 20% 空闲）</li>
</ol>
<h3>6.2 更新问题</h3>
<ol>
<li>设置 &gt; Windows 更新 &gt; 暂停更新</li>
<li>运行 Windows 更新疑难解答</li>
<li>手动下载更新包安装</li>
</ol>
<h2>七、总结</h2>
<p>掌握这些 Windows 技巧可以大幅提升效率。建议：</p>
<ol>
<li>每天练习 2-3 个快捷键</li>
<li>安装 PowerToys 工具集</li>
<li>定期清理系统和启动项</li>
<li>善用虚拟桌面分隔任务</li>
</ol>
<hr>
<p><em>关注我们获取更多 Windows 使用教程和效率技巧！</em></p>
<p><a href="https://www.dixunblog.cn/1481.html">Windows 11 必学快捷键与效率技巧 &#8211; 基础篇</a>最先出现在<a href="https://www.dixunblog.cn">帝讯博客</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dixunblog.cn/1481.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 fetchpriority="high" 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>
	</channel>
</rss>
