<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Python on 学无止境</title>
		<link>https://sunnnnner.github.io/categories/python/</link>
		<description>Recent content in Python on 学无止境</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Wed, 15 Jul 2026 10:14:02 +0800</lastBuildDate>
		
			<atom:link href="https://sunnnnner.github.io/categories/python/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Python代码审查的Git Hook实现指南</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5%E7%9A%84git-hook%E5%AE%9E%E7%8E%B0%E6%8C%87%E5%8D%97/</link>
				<pubDate>Thu, 16 Jan 2025 16:14:01 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E4%BB%A3%E7%A0%81%E5%AE%A1%E6%9F%A5%E7%9A%84git-hook%E5%AE%9E%E7%8E%B0%E6%8C%87%E5%8D%97/</guid>
				<description></description>
			</item>
			<item>
				<title>python性能分析与数据结构</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E5%86%85%E7%BD%AE%E7%B1%BB%E5%9E%8B%E6%80%A7%E8%83%BD%E5%88%86%E6%9E%90%E4%B8%8E%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/</link>
				<pubDate>Mon, 17 Apr 2023 10:52:21 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E5%86%85%E7%BD%AE%E7%B1%BB%E5%9E%8B%E6%80%A7%E8%83%BD%E5%88%86%E6%9E%90%E4%B8%8E%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/</guid>
				<description></description>
			</item>
			<item>
				<title>函数进行单元测试</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E5%87%BD%E6%95%B0%E8%BF%9B%E8%A1%8C%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95/</link>
				<pubDate>Wed, 12 Apr 2023 15:46:40 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E5%87%BD%E6%95%B0%E8%BF%9B%E8%A1%8C%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95/</guid>
				<description></description>
			</item>
			<item>
				<title>列表字典去重求和</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E5%88%97%E8%A1%A8%E5%AD%97%E5%85%B8%E5%8E%BB%E9%87%8D%E6%B1%82%E5%92%8C/</link>
				<pubDate>Sat, 11 Mar 2023 15:46:40 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E5%88%97%E8%A1%A8%E5%AD%97%E5%85%B8%E5%8E%BB%E9%87%8D%E6%B1%82%E5%92%8C/</guid>
				<description></description>
			</item>
			<item>
				<title>Python模板库mako语法</title>
				<link>https://sunnnnner.github.io/posts/python/%E6%A8%A1%E5%9D%97/python%E8%8E%AB%E6%9D%BF%E5%9D%97mako%E8%AF%AD%E6%B3%95/</link>
				<pubDate>Fri, 10 Mar 2023 15:46:40 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E6%A8%A1%E5%9D%97/python%E8%8E%AB%E6%9D%BF%E5%9D%97mako%E8%AF%AD%E6%B3%95/</guid>
				<description></description>
			</item>
			<item>
				<title> Python异常处理机制详解</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A13-%E5%BC%82%E5%B8%B8/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A13-%E5%BC%82%E5%B8%B8/</guid>
				<description></description>
			</item>
			<item>
				<title>pygame</title>
				<link>https://sunnnnner.github.io/posts/python/%E6%A8%A1%E5%9D%97/pygame%E6%A8%A1%E5%9D%97%E5%BA%94%E7%94%A8/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E6%A8%A1%E5%9D%97/pygame%E6%A8%A1%E5%9D%97%E5%BA%94%E7%94%A8/</guid>
				<description>&lt;hr&gt;&#xA;&lt;h1 id=&#34;pygame&#34;&gt;pygame&lt;/h1&gt;&#xA;&lt;hr&gt;</description>
			</item>
			<item>
				<title>PyMySQL 数据库操作指南</title>
				<link>https://sunnnnner.github.io/posts/mysql/pymysql%E9%93%BE%E6%8E%A5/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/mysql/pymysql%E9%93%BE%E6%8E%A5/</guid>
				<description></description>
			</item>
			<item>
				<title>python 基础</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python-%E5%9F%BA%E7%A1%80/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python-%E5%9F%BA%E7%A1%80/</guid>
				<description></description>
			</item>
			<item>
				<title>python：函数</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%87%BD%E6%95%B0/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%87%BD%E6%95%B0/</guid>
				<description>&lt;hr&gt;&#xA;&lt;h3 id=&#34;函数&#34;&gt;函数&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;1、常使用的模块&lt;/li&gt;&#xA;&lt;li&gt;2、模块的代码比较多&lt;/li&gt;&#xA;&lt;li&gt;3、具有独立功能的代码块组织为一个小模块，这就是函数&lt;/li&gt;&#xA;&lt;li&gt;4、函数的优点：提高代码的复用性，提高代码的可维护性&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>python元祖与字典</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%85%83%E7%A5%96%E4%B8%8E%E5%AD%97%E5%85%B8/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%85%83%E7%A5%96%E4%B8%8E%E5%AD%97%E5%85%B8/</guid>
				<description>&lt;h1 id=&#34;元祖&#34;&gt;元祖&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;tuple（）&lt;/code&gt;定义元组&lt;/li&gt;&#xA;&lt;li&gt;元组中存放的数据可以使int,str list diec&lt;/li&gt;&#xA;&lt;li&gt;读取元组的值使用下标&lt;/li&gt;&#xA;&lt;li&gt;元组的修改和删除是不支持的&lt;/li&gt;&#xA;&lt;li&gt;但是列表支持修改a[0]=99元组不允许删除部分：remove pop del元组不能使用&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Python内存管理与垃圾回收机制详解</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6%E5%86%85%E5%BB%BA%E5%B1%9E%E6%80%A7%E5%92%8C%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/%E5%9E%83%E5%9C%BE%E5%9B%9E%E6%94%B6%E5%86%85%E5%BB%BA%E5%B1%9E%E6%80%A7%E5%92%8C%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/</guid>
				<description>&lt;h1 id=&#34;垃圾回收&#34;&gt;垃圾回收&lt;/h1&gt;&#xA;&lt;hr&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;GC(Garbage collection)垃圾回收&lt;/li&gt;&#xA;&lt;li&gt;python采用的是引用计数机制为主，标记-2清楚和分代收集（隔代回收，分代回收）两种机制&#xA;为辅的策略&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>python判断语句</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%88%A4%E6%96%AD%E8%AF%AD%E5%8F%A5%E4%B8%8E%E5%BE%AA%E7%8E%AF/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%88%A4%E6%96%AD%E8%AF%AD%E5%8F%A5%E4%B8%8E%E5%BE%AA%E7%8E%AF/</guid>
				<description>&lt;h1 id=&#34;if判断语句&#34;&gt;if判断语句&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;if 要判断的条件：&lt;/li&gt;&#xA;&lt;li&gt;条件成立时，要做的事情&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Python多线程编程指南</title>
				<link>https://sunnnnner.github.io/posts/linux/liunx-%E7%BA%BF%E7%A8%8B/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/linux/liunx-%E7%BA%BF%E7%A8%8B/</guid>
				<description></description>
			</item>
			<item>
				<title>Python多进程编程指南</title>
				<link>https://sunnnnner.github.io/posts/linux/liunx%E7%BC%96%E7%A8%8B-%E8%BF%9B%E7%A8%8B/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/linux/liunx%E7%BC%96%E7%A8%8B-%E8%BF%9B%E7%A8%8B/</guid>
				<description></description>
			</item>
			<item>
				<title>python字符串</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%AD%97%E7%AC%A6%E4%B8%B2/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%AD%97%E7%AC%A6%E4%B8%B2/</guid>
				<description>&lt;h1 id=&#34;字符串&#34;&gt;字符串&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;name[0]  代表取第一个值的下标返回&lt;/li&gt;&#xA;&lt;li&gt;name[len(name)-1]代表取最后一个值并返回&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>python模块</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E6%A8%A1%E5%9D%97/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E6%A8%A1%E5%9D%97/</guid>
				<description></description>
			</item>
			<item>
				<title>Python设计模式详解</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1-%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1-%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/</guid>
				<description>&lt;h1 id=&#34;设计模式&#34;&gt;设计模式&lt;/h1&gt;&#xA;&lt;hr&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;设计模式是高成次的方案，并不关心具体的实现细节&lt;/li&gt;&#xA;&lt;li&gt;比如算法和数据结构和网页。对应正在尝试解决问题，何种算法和数据结构最优，则是由软件工程师自己把握。&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Python面向对象编程详解</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1/</guid>
				<description>&lt;ul&gt;&#xA;&lt;li&gt;object oriented programming&lt;/li&gt;&#xA;&lt;li&gt;OOP面向对象程序设计&lt;/li&gt;&#xA;&lt;li&gt;java C#只支持面向对象编程&lt;/li&gt;&#xA;&lt;li&gt;python既支持面向过程编程也支持面向对象编程&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Python面向对象高级特性详解</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A12--%E5%B0%81%E8%A3%85/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A12--%E5%B0%81%E8%A3%85/</guid>
				<description>&lt;h1 id=&#34;类属性&#34;&gt;类属性&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;类属性写在类下面&lt;/li&gt;&#xA;&lt;li&gt;0、类属性可以通过：&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt;类名.属性  或者  对象名.属性&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;1、如何改变类属性的值&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;pre&gt;&lt;code&gt; 类的属性修改要通过类名.属性=新值来修改&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;2、如果有多个对象，类属性有什么变化&lt;/li&gt;&#xA;&lt;/ul&gt;</description>
			</item>
			<item>
				<title>Python高级特性：对象比较、拷贝机制与作用域</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E6%B7%B1%E6%B5%85%E6%8B%B7%E8%B4%9D/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E6%B7%B1%E6%B5%85%E6%8B%B7%E8%B4%9D/</guid>
				<description></description>
			</item>
			<item>
				<title>Python高级特性：生成器、迭代器、闭包与装饰器</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E7%94%9F%E6%88%90%E5%99%A8%E8%BF%AD%E4%BB%A3%E5%99%A8%E9%97%AD%E5%8C%85%E8%A3%85%E9%A5%B0%E5%99%A8/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/%E7%94%9F%E6%88%90%E5%99%A8%E8%BF%AD%E4%BB%A3%E5%99%A8%E9%97%AD%E5%8C%85%E8%A3%85%E9%A5%B0%E5%99%A8/</guid>
				<description></description>
			</item>
			<item>
				<title>正则表达式</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/</guid>
				<description>&lt;hr&gt;</description>
			</item>
			<item>
				<title>网络-并发服务器</title>
				<link>https://sunnnnner.github.io/posts/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C-%E5%B9%B6%E5%8F%91%E6%9C%8D%E5%8A%A1%E5%99%A8/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C-%E5%B9%B6%E5%8F%91%E6%9C%8D%E5%8A%A1%E5%99%A8/</guid>
				<description></description>
			</item>
			<item>
				<title>网络概念与UDP编程</title>
				<link>https://sunnnnner.github.io/posts/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E6%A6%82%E5%BF%B5%E5%92%8Cudp%E7%BC%96%E7%A8%8B/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E6%A6%82%E5%BF%B5%E5%92%8Cudp%E7%BC%96%E7%A8%8B/</guid>
				<description>&lt;h2 id=&#34;1-网络基础概念&#34;&gt;1. 网络基础概念&lt;/h2&gt;&#xA;&lt;h3 id=&#34;11-网络定义&#34;&gt;1.1 网络定义&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;电路网络：由电子元件组成的信号传输系统&lt;/li&gt;&#xA;&lt;li&gt;三大网络：&#xA;&lt;ol&gt;&#xA;&lt;li&gt;电信网络&lt;/li&gt;&#xA;&lt;li&gt;有线电视网络&lt;/li&gt;&#xA;&lt;li&gt;计算机网络（互联网）&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;12-网络层次&#34;&gt;1.2 网络层次&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;网络体系结构：&#xA;- 应用层&#xA;- 传输层&#xA;- 网际层（网络层）&#xA;- 网络接口层（链路层）&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;2-本地服务器配置&#34;&gt;2. 本地服务器配置&lt;/h2&gt;&#xA;&lt;h3 id=&#34;21-快速启动http服务&#34;&gt;2.1 快速启动HTTP服务&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# Python 2&#xA;python -m SimpleHTTPServer 8080&#xA;&#xA;# Python 3&#xA;python -m http.server 8080&#xA;&#xA;# 访问地址&#xA;http://127.0.0.1:8080  # 本机回环地址&#xA;http://localhost:8080   # 本机域名&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;3-socket编程基础&#34;&gt;3. Socket编程基础&lt;/h2&gt;&#xA;&lt;h3 id=&#34;31-socket类型&#34;&gt;3.1 Socket类型&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;import socket&#xA;&#xA;# 创建Socket对象&#xA;# 本地进程通信&#xA;unix_socket = socket.socket(socket.AF_UNIX)&#xA;&#xA;# 网络通信&#xA;inet_socket = socket.socket(socket.AF_INET)&#xA;&#xA;# 协议类型&#xA;tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # TCP协议&#xA;udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)   # UDP协议&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;32-socket地址族&#34;&gt;3.2 Socket地址族&lt;/h3&gt;&#xA;&lt;table&gt;&#xA;&#x9;&lt;thead&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;地址族&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;说明&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;用途&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/thead&gt;&#xA;&#x9;&lt;tbody&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;AF_UNIX&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;本地通信&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;同一台计算机进程间通信&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;AF_INET&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;IPv4网络&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;互联网通信&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;AF_INET6&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;IPv6网络&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;下一代互联网通信&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h2 id=&#34;4-udp通信&#34;&gt;4. UDP通信&lt;/h2&gt;&#xA;&lt;h3 id=&#34;41-udp特点&#34;&gt;4.1 UDP特点&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;无连接通信协议&lt;/li&gt;&#xA;&lt;li&gt;支持广播发送&lt;/li&gt;&#xA;&lt;li&gt;数据包大小限制（64KB）&lt;/li&gt;&#xA;&lt;li&gt;不保证可靠传输&lt;/li&gt;&#xA;&lt;li&gt;不保证数据顺序&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3 id=&#34;42-基本udp通信示例&#34;&gt;4.2 基本UDP通信示例&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;import socket&#xA;&#xA;# 创建UDP Socket&#xA;udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)&#xA;&#xA;# 绑定本地地址和端口&#xA;local_addr = (&amp;#39;&amp;#39;, 8888)  # 空字符串表示本机所有IP&#xA;udp_socket.bind(local_addr)&#xA;&#xA;# 发送数据&#xA;target_addr = (&amp;#39;192.168.1.100&amp;#39;, 8888)&#xA;message = &amp;#34;Hello, UDP!&amp;#34;&#xA;udp_socket.sendto(message.encode(&amp;#39;utf-8&amp;#39;), target_addr)&#xA;&#xA;# 接收数据&#xA;while True:&#xA;    data, addr = udp_socket.recvfrom(1024)  # 缓冲区大小1024字节&#xA;    print(f&amp;#34;从{addr}接收到: {data.decode(&amp;#39;utf-8&amp;#39;)}&amp;#34;)&#xA;&#xA;# 关闭Socket&#xA;udp_socket.close()&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;43-端口绑定&#34;&gt;4.3 端口绑定&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# 服务端绑定固定端口&#xA;server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)&#xA;server_socket.bind((&amp;#39;&amp;#39;, 80))  # 绑定80端口&#xA;&#xA;# 客户端使用随机端口&#xA;client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)&#xA;# 系统自动分配端口&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;5-通信模式&#34;&gt;5. 通信模式&lt;/h2&gt;&#xA;&lt;h3 id=&#34;51-通信方式对比&#34;&gt;5.1 通信方式对比&lt;/h3&gt;&#xA;&lt;table&gt;&#xA;&#x9;&lt;thead&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;模式&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;特点&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;类比&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/thead&gt;&#xA;&#x9;&lt;tbody&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;单工&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;单向传输&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;广播&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;半双工&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;双向交替传输&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;对讲机&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;全双工&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;双向同时传输&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;电话&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h3 id=&#34;52-数据编解码&#34;&gt;5.2 数据编解码&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# 发送数据编码&#xA;message = &amp;#34;你好&amp;#34;&#xA;encoded_data = message.encode(&amp;#39;utf-8&amp;#39;)&#xA;&#xA;# 接收数据解码&#xA;decoded_data = received_data.decode(&amp;#39;utf-8&amp;#39;)&#xA;&#xA;# 支持的编码&#xA;encodings = [&amp;#39;utf-8&amp;#39;, &amp;#39;gb2312&amp;#39;, &amp;#39;ascii&amp;#39;]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;6-最佳实践&#34;&gt;6. 最佳实践&lt;/h2&gt;&#xA;&lt;h3 id=&#34;61-socket编程建议&#34;&gt;6.1 Socket编程建议&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;始终使用 with 语句管理socket&lt;/li&gt;&#xA;&lt;li&gt;设置适当的超时时间&lt;/li&gt;&#xA;&lt;li&gt;正确处理异常&lt;/li&gt;&#xA;&lt;li&gt;及时关闭不用的socket&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;h3 id=&#34;62-示例代码&#34;&gt;6.2 示例代码&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;import socket&#xA;&#xA;def create_udp_server(host=&amp;#39;&amp;#39;, port=8888):&#xA;    with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as server:&#xA;        server.bind((host, port))&#xA;        server.settimeout(60)  # 60秒超时&#xA;        try:&#xA;            while True:&#xA;                data, addr = server.recvfrom(1024)&#xA;                if not data:&#xA;                    break&#xA;                # 处理数据&#xA;                process_data(data, addr)&#xA;        except socket.timeout:&#xA;            print(&amp;#34;服务器超时&amp;#34;)&#xA;        except Exception as e:&#xA;            print(f&amp;#34;发生错误: {e}&amp;#34;)&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;63-安全建议&#34;&gt;6.3 安全建议&lt;/h3&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;验证数据来源&lt;/li&gt;&#xA;&lt;li&gt;限制数据包大小&lt;/li&gt;&#xA;&lt;li&gt;实现超时机制&lt;/li&gt;&#xA;&lt;li&gt;做好错误处理&lt;/li&gt;&#xA;&lt;li&gt;考虑加密传输&lt;/li&gt;&#xA;&lt;/ol&gt;</description>
			</item>
			<item>
				<title>计算机存储单位与Python字符串操作详解</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%92%8C%E5%88%97%E8%A1%A8/</link>
				<pubDate>Tue, 12 Jul 2022 14:37:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%92%8C%E5%88%97%E8%A1%A8/</guid>
				<description></description>
			</item>
			<item>
				<title>Python中Queue的线程安全</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E4%B8%ADqueue%E7%9A%84%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8/</link>
				<pubDate>Fri, 08 Jul 2022 09:39:21 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E4%B8%ADqueue%E7%9A%84%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8/</guid>
				<description></description>
			</item>
			<item>
				<title>Python线程安全</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8/</link>
				<pubDate>Fri, 08 Jul 2022 09:32:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E7%BA%BF%E7%A8%8B%E5%AE%89%E5%85%A8/</guid>
				<description></description>
			</item>
			<item>
				<title>Python虚拟环境pipenv使用</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83/python%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83pipenv%E4%BD%BF%E7%94%A8/</link>
				<pubDate>Thu, 07 Jul 2022 10:08:33 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83/python%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83pipenv%E4%BD%BF%E7%94%A8/</guid>
				<description></description>
			</item>
			<item>
				<title>使用itertools处理python嵌套列表问题</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/python%E5%88%97%E8%A1%A8%E4%BD%BF%E7%94%A8itertools%E5%A4%84%E7%90%86/</link>
				<pubDate>Fri, 13 May 2022 13:39:13 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/python%E5%88%97%E8%A1%A8%E4%BD%BF%E7%94%A8itertools%E5%A4%84%E7%90%86/</guid>
				<description></description>
			</item>
			<item>
				<title>Pysocket</title>
				<link>https://sunnnnner.github.io/posts/python/%E6%A8%A1%E5%9D%97/pysocket/</link>
				<pubDate>Thu, 10 Mar 2022 15:46:40 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E6%A8%A1%E5%9D%97/pysocket/</guid>
				<description></description>
			</item>
			<item>
				<title>Ubuntu20.04 LTS编译python3.7</title>
				<link>https://sunnnnner.github.io/posts/linux/ubuntu-install-python3.7/</link>
				<pubDate>Fri, 06 Aug 2021 19:29:05 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/linux/ubuntu-install-python3.7/</guid>
				<description>&lt;h1 id=&#34;ubuntu2004-lts编译-python371&#34;&gt;ubuntu20.04 LTS编译 &lt;a href=&#34;https://www.python.org/downloads/release/python-371/&#34;&gt;python3.7.1&lt;/a&gt;&lt;/h1&gt;</description>
			</item>
			<item>
				<title>Python日期转换</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/python%E6%97%A5%E6%9C%9F%E8%BD%AC%E6%8D%A2/</link>
				<pubDate>Tue, 10 Dec 2019 15:43:08 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/python%E6%97%A5%E6%9C%9F%E8%BD%AC%E6%8D%A2/</guid>
				<description></description>
			</item>
			<item>
				<title>Python Logging 完整指南</title>
				<link>https://sunnnnner.github.io/posts/django/log-basicconfig%E5%87%BD%E6%95%B0/</link>
				<pubDate>Thu, 05 Dec 2019 15:40:17 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/django/log-basicconfig%E5%87%BD%E6%95%B0/</guid>
				<description></description>
			</item>
			<item>
				<title>Divmod函数</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/divmod%E5%87%BD%E6%95%B0/</link>
				<pubDate>Sun, 01 Dec 2019 15:39:29 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/divmod%E5%87%BD%E6%95%B0/</guid>
				<description></description>
			</item>
			<item>
				<title>Python Collections Duque函数演示</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/python-collections-duque%E5%87%BD%E6%95%B0%E6%BC%94%E7%A4%BA/</link>
				<pubDate>Tue, 15 Oct 2019 15:33:37 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/python-collections-duque%E5%87%BD%E6%95%B0%E6%BC%94%E7%A4%BA/</guid>
				<description></description>
			</item>
			<item>
				<title>Getattr函数</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/getattr%E5%87%BD%E6%95%B0/</link>
				<pubDate>Mon, 14 Oct 2019 15:31:31 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/getattr%E5%87%BD%E6%95%B0/</guid>
				<description></description>
			</item>
			<item>
				<title>Hasattr函数</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/hasattr%E5%87%BD%E6%95%B0/</link>
				<pubDate>Sun, 13 Oct 2019 15:30:12 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%86%85%E5%BB%BA%E5%87%BD%E6%95%B0/hasattr%E5%87%BD%E6%95%B0/</guid>
				<description></description>
			</item>
			<item>
				<title>Os模块</title>
				<link>https://sunnnnner.github.io/posts/linux/os%E6%A8%A1%E5%9D%97/</link>
				<pubDate>Thu, 10 Oct 2019 14:20:46 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/linux/os%E6%A8%A1%E5%9D%97/</guid>
				<description></description>
			</item>
			<item>
				<title>Python实现AES加密</title>
				<link>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E5%AE%9E%E7%8E%B0aes%E5%8A%A0%E5%AF%86/</link>
				<pubDate>Sat, 05 Oct 2019 14:14:41 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E5%AE%9E%E7%8E%B0aes%E5%8A%A0%E5%AF%86/</guid>
				<description></description>
			</item>
			<item>
				<title>动态网页爬取</title>
				<link>https://sunnnnner.github.io/posts/python/%E7%88%AC%E8%99%AB/%E5%8A%A8%E6%80%81%E7%BD%91%E9%A1%B5%E7%88%AC%E5%8F%96/</link>
				<pubDate>Wed, 11 Sep 2019 11:42:10 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E7%88%AC%E8%99%AB/%E5%8A%A8%E6%80%81%E7%BD%91%E9%A1%B5%E7%88%AC%E5%8F%96/</guid>
				<description></description>
			</item>
			<item>
				<title>RESTful API 设计指南</title>
				<link>https://sunnnnner.github.io/posts/restful/restful%E8%A7%84%E8%8C%83/</link>
				<pubDate>Fri, 06 Sep 2019 11:36:12 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/restful/restful%E8%A7%84%E8%8C%83/</guid>
				<description>&lt;h2 id=&#34;1-什么是restful&#34;&gt;1. 什么是RESTful&lt;/h2&gt;&#xA;&lt;p&gt;RESTful是一种软件架构风格，主要用于规范客户端与服务端的交互。它不是标准，而是一套设计原则和约束条件，帮助我们创建更优雅的API接口。&lt;/p&gt;&#xA;&lt;h2 id=&#34;2-核心原则&#34;&gt;2. 核心原则&lt;/h2&gt;&#xA;&lt;h3 id=&#34;21-面向资源&#34;&gt;2.1 面向资源&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;使用名词表示资源&lt;/li&gt;&#xA;&lt;li&gt;URL中避免使用动词&lt;/li&gt;&#xA;&lt;li&gt;资源应该是名词的复数形式&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# 好的例子&#xA;GET /api/v1/users          # 获取用户列表&#xA;GET /api/v1/users/123      # 获取特定用户&#xA;POST /api/v1/users         # 创建用户&#xA;&#xA;# 不好的例子&#xA;GET /api/v1/getUsers&#xA;POST /api/v1/createUser&#xA;PUT /api/v1/updateUser&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;22-http方法&#34;&gt;2.2 HTTP方法&lt;/h3&gt;&#xA;&lt;table&gt;&#xA;&#x9;&lt;thead&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;方法&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;用途&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;特点&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/thead&gt;&#xA;&#x9;&lt;tbody&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;GET&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;获取资源&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;安全且幂等&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;POST&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;创建资源&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;非幂等&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;PUT&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;更新资源（完整）&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;幂等&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;DELETE&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;删除资源&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;幂等&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;PATCH&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;更新资源（部分）&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;幂等&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h2 id=&#34;3-设计规范&#34;&gt;3. 设计规范&lt;/h2&gt;&#xA;&lt;h3 id=&#34;31-url设计&#34;&gt;3.1 URL设计&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# 版本号&#xA;/api/v1/resources&#xA;&#xA;# 资源层级&#xA;/api/v1/users/{user_id}/orders/{order_id}&#xA;&#xA;# 过滤、排序、分页&#xA;/api/v1/users?page=2&amp;amp;size=10&#xA;/api/v1/products?sort=price_desc&#xA;/api/v1/orders?status=pending&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;32-安全性&#34;&gt;3.2 安全性&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;使用HTTPS协议&lt;/li&gt;&#xA;&lt;li&gt;实现身份认证&lt;/li&gt;&#xA;&lt;li&gt;使用OAuth2等授权机制&lt;/li&gt;&#xA;&lt;li&gt;实施速率限制&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;33-状态码使用&#34;&gt;3.3 状态码使用&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# 常用状态码&#xA;200 OK              # 请求成功&#xA;201 Created         # 创建成功&#xA;204 No Content      # 删除成功&#xA;400 Bad Request     # 请求错误&#xA;401 Unauthorized    # 未授权&#xA;403 Forbidden       # 禁止访问&#xA;404 Not Found       # 资源不存在&#xA;500 Server Error    # 服务器错误&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;34-响应格式&#34;&gt;3.4 响应格式&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# 成功响应&#xA;{&#xA;    &amp;#34;status&amp;#34;: &amp;#34;success&amp;#34;,&#xA;    &amp;#34;data&amp;#34;: {&#xA;        &amp;#34;id&amp;#34;: 1,&#xA;        &amp;#34;name&amp;#34;: &amp;#34;John Doe&amp;#34;,&#xA;        &amp;#34;email&amp;#34;: &amp;#34;john@example.com&amp;#34;&#xA;    },&#xA;    &amp;#34;links&amp;#34;: {&#xA;        &amp;#34;self&amp;#34;: &amp;#34;/api/v1/users/1&amp;#34;,&#xA;        &amp;#34;orders&amp;#34;: &amp;#34;/api/v1/users/1/orders&amp;#34;&#xA;    }&#xA;}&#xA;&#xA;# 错误响应&#xA;{&#xA;    &amp;#34;status&amp;#34;: &amp;#34;error&amp;#34;,&#xA;    &amp;#34;code&amp;#34;: &amp;#34;USER_NOT_FOUND&amp;#34;,&#xA;    &amp;#34;message&amp;#34;: &amp;#34;User with id 1 not found&amp;#34;,&#xA;    &amp;#34;documentation_url&amp;#34;: &amp;#34;/api/docs#errors&amp;#34;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;4-最佳实践&#34;&gt;4. 最佳实践&lt;/h2&gt;&#xA;&lt;h3 id=&#34;41-版本控制&#34;&gt;4.1 版本控制&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# URL中的版本号&#xA;/api/v1/users&#xA;&#xA;# Header中的版本号&#xA;Accept: application/vnd.company.api+json;version=1&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;42-hateoas&#34;&gt;4.2 HATEOAS&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;{&#xA;    &amp;#34;data&amp;#34;: {&#xA;        &amp;#34;id&amp;#34;: 123,&#xA;        &amp;#34;status&amp;#34;: &amp;#34;pending&amp;#34;&#xA;    },&#xA;    &amp;#34;_links&amp;#34;: {&#xA;        &amp;#34;self&amp;#34;: &amp;#34;/api/v1/orders/123&amp;#34;,&#xA;        &amp;#34;cancel&amp;#34;: &amp;#34;/api/v1/orders/123/cancel&amp;#34;,&#xA;        &amp;#34;payment&amp;#34;: &amp;#34;/api/v1/orders/123/payment&amp;#34;&#xA;    }&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;43-查询参数规范&#34;&gt;4.3 查询参数规范&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;# 分页&#xA;/api/v1/users?page=2&amp;amp;per_page=100&#xA;&#xA;# 过滤&#xA;/api/v1/users?status=active&amp;amp;role=admin&#xA;&#xA;# 排序&#xA;/api/v1/users?sort=created_at:desc&#xA;&#xA;# 字段选择&#xA;/api/v1/users?fields=id,name,email&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;5-文档和测试&#34;&gt;5. 文档和测试&lt;/h2&gt;&#xA;&lt;h3 id=&#34;51-api文档&#34;&gt;5.1 API文档&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;使用OpenAPI/Swagger&lt;/li&gt;&#xA;&lt;li&gt;提供详细的参数说明&lt;/li&gt;&#xA;&lt;li&gt;包含请求和响应示例&lt;/li&gt;&#xA;&lt;li&gt;说明错误处理机制&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;52-测试建议&#34;&gt;5.2 测试建议&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;编写完整的单元测试&lt;/li&gt;&#xA;&lt;li&gt;进行集成测试&lt;/li&gt;&#xA;&lt;li&gt;性能测试&lt;/li&gt;&#xA;&lt;li&gt;安全性测试&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;6-注意事项&#34;&gt;6. 注意事项&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;保持API的简单性和一致性&lt;/li&gt;&#xA;&lt;li&gt;正确处理错误情况&lt;/li&gt;&#xA;&lt;li&gt;实现适当的缓存机制&lt;/li&gt;&#xA;&lt;li&gt;考虑向后兼容性&lt;/li&gt;&#xA;&lt;li&gt;提供充分的文档说明&lt;/li&gt;&#xA;&lt;li&gt;实现合适的监控机制&lt;/li&gt;&#xA;&lt;/ol&gt;</description>
			</item>
			<item>
				<title>Python字符串操作</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%93%8D%E4%BD%9C/</link>
				<pubDate>Tue, 03 Sep 2019 11:25:09 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%93%8D%E4%BD%9C/</guid>
				<description></description>
			</item>
			<item>
				<title>修改macos自带Python版本（尽量不要修改）</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83/%E4%BF%AE%E6%94%B9macos%E8%87%AA%E5%B8%A6python%E7%89%88%E6%9C%AC%E5%B0%BD%E9%87%8F%E4%B8%8D%E8%A6%81%E4%BF%AE%E6%94%B9/</link>
				<pubDate>Mon, 02 Sep 2019 11:24:14 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83/%E4%BF%AE%E6%94%B9macos%E8%87%AA%E5%B8%A6python%E7%89%88%E6%9C%AC%E5%B0%BD%E9%87%8F%E4%B8%8D%E8%A6%81%E4%BF%AE%E6%94%B9/</guid>
				<description></description>
			</item>
			<item>
				<title>Python版本控制以及虚拟环境的安装</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83/python%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E4%BB%A5%E5%8F%8A%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83%E7%9A%84%E5%AE%89%E8%A3%85/</link>
				<pubDate>Sun, 01 Sep 2019 11:22:47 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83/python%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6%E4%BB%A5%E5%8F%8A%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83%E7%9A%84%E5%AE%89%E8%A3%85/</guid>
				<description></description>
			</item>
			<item>
				<title>Session&#43;cookie和使用token有什么区别</title>
				<link>https://sunnnnner.github.io/posts/%E7%BD%91%E7%BB%9C/session&#43;cookie%E5%92%8C%E4%BD%BF%E7%94%A8tocken%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB/</link>
				<pubDate>Sun, 03 Feb 2019 10:51:26 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/%E7%BD%91%E7%BB%9C/session&#43;cookie%E5%92%8C%E4%BD%BF%E7%94%A8tocken%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB/</guid>
				<description>&lt;h2 id=&#34;1-基本概念对比&#34;&gt;1. 基本概念对比&lt;/h2&gt;&#xA;&lt;h3 id=&#34;11-存储位置&#34;&gt;1.1 存储位置&lt;/h3&gt;&#xA;&lt;table&gt;&#xA;&#x9;&lt;thead&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;机制&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;存储位置&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;安全性&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;th&gt;性能影响&lt;/th&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/thead&gt;&#xA;&#x9;&lt;tbody&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;Cookie&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;客户端浏览器&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;低&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;低&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;Session&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;服务器&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;高&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;高&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&#x9;&#x9;&lt;tr&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;Token&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;客户端&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;高&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&#x9;&#x9;&lt;td&gt;低&lt;/td&gt;&#xA;&#x9;&#x9;&#x9;&lt;/tr&gt;&#xA;&#x9;&lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h3 id=&#34;12-工作原理&#34;&gt;1.2 工作原理&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&#xA;&#xA;# Cookie工作流程&#xA;1. 服务器发送Cookie&#xA;Set-Cookie: user=john; expires=Sat, 31 Dec 2023 23:59:59 GMT&#xA;&#xA;2. 浏览器存储Cookie&#xA;&#xA;3. 后续请求自动携带Cookie&#xA;Cookie: user=john&#xA;&#xA;# Session工作流程&#xA;1. 用户登录&#xA;2. 服务器创建Session并生成SessionID&#xA;3. 将SessionID通过Cookie发送给客户端&#xA;4. 客户端请求时携带SessionID&#xA;5. 服务器验证SessionID并返回数据&#xA;&#xA;# Token工作流程&#xA;1. 用户登录后服务器生成Token&#xA;2. 客户端存储Token&#xA;3. 请求时在Header中携带Token&#xA;Authorization: Bearer &amp;lt;token&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;2-特点比较&#34;&gt;2. 特点比较&lt;/h2&gt;&#xA;&lt;h3 id=&#34;21-cookie&#34;&gt;2.1 Cookie&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;优点：&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;减轻服务器负担&lt;/li&gt;&#xA;&lt;li&gt;实现简单&lt;/li&gt;&#xA;&lt;li&gt;支持浏览器原生&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;缺点：&lt;/p&gt;</description>
			</item>
			<item>
				<title>进程、线程与协程的深入理解</title>
				<link>https://sunnnnner.github.io/posts/linux/%E7%BA%BF%E7%A8%8B%E8%BF%9B%E7%A8%8B%E5%8D%8F%E7%A8%8B/</link>
				<pubDate>Sat, 02 Feb 2019 10:46:49 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/linux/%E7%BA%BF%E7%A8%8B%E8%BF%9B%E7%A8%8B%E5%8D%8F%E7%A8%8B/</guid>
				<description></description>
			</item>
			<item>
				<title>广度优先遍历二叉树</title>
				<link>https://sunnnnner.github.io/posts/%E7%AE%97%E6%B3%95/%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E9%81%8D%E5%8E%86%E4%BA%8C%E5%8F%89%E6%A0%91/</link>
				<pubDate>Fri, 01 Feb 2019 10:44:14 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/%E7%AE%97%E6%B3%95/%E5%B9%BF%E5%BA%A6%E4%BC%98%E5%85%88%E9%81%8D%E5%8E%86%E4%BA%8C%E5%8F%89%E6%A0%91/</guid>
				<description></description>
			</item>
			<item>
				<title>深度优先遍历二叉树</title>
				<link>https://sunnnnner.github.io/posts/%E7%AE%97%E6%B3%95/%E6%B7%B1%E5%BA%A6%E4%BC%98%E5%85%88%E9%81%8D%E5%8E%86%E4%BA%8C%E5%8F%89%E6%A0%91/</link>
				<pubDate>Tue, 01 Jan 2019 10:41:11 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/%E7%AE%97%E6%B3%95/%E6%B7%B1%E5%BA%A6%E4%BC%98%E5%85%88%E9%81%8D%E5%8E%86%E4%BA%8C%E5%8F%89%E6%A0%91/</guid>
				<description></description>
			</item>
			<item>
				<title>Python字典按值排序</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E5%AD%97%E5%85%B8%E6%8C%89%E5%80%BC%E6%8E%92%E5%BA%8F/</link>
				<pubDate>Sun, 02 Dec 2018 10:39:55 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E5%AD%97%E5%85%B8%E6%8C%89%E5%80%BC%E6%8E%92%E5%BA%8F/</guid>
				<description></description>
			</item>
			<item>
				<title>Python上楼梯问题</title>
				<link>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E4%B8%8A%E6%A5%BC%E6%A2%AF%E9%97%AE%E9%A2%98/</link>
				<pubDate>Sat, 01 Dec 2018 10:39:04 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E4%B8%8A%E6%A5%BC%E6%A2%AF%E9%97%AE%E9%A2%98/</guid>
				<description></description>
			</item>
			<item>
				<title>Python快速排序</title>
				<link>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F/</link>
				<pubDate>Thu, 01 Nov 2018 10:38:06 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F/</guid>
				<description></description>
			</item>
			<item>
				<title>Python链表</title>
				<link>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E9%93%BE%E8%A1%A8/</link>
				<pubDate>Tue, 02 Oct 2018 10:37:28 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E9%93%BE%E8%A1%A8/</guid>
				<description></description>
			</item>
			<item>
				<title>Python二分查找</title>
				<link>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE/</link>
				<pubDate>Mon, 01 Oct 2018 10:36:53 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E4%BA%8C%E5%88%86%E6%9F%A5%E6%89%BE/</guid>
				<description></description>
			</item>
			<item>
				<title>Python冒泡算法</title>
				<link>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E5%86%92%E6%B3%A1%E7%AE%97%E6%B3%95/</link>
				<pubDate>Sat, 08 Sep 2018 10:36:08 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E7%AE%97%E6%B3%95/python%E5%86%92%E6%B3%A1%E7%AE%97%E6%B3%95/</guid>
				<description></description>
			</item>
			<item>
				<title>Python装饰器</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E8%A3%85%E9%A5%B0%E5%99%A8/</link>
				<pubDate>Fri, 07 Sep 2018 10:35:21 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%BF%9B%E9%98%B6/python%E8%A3%85%E9%A5%B0%E5%99%A8/</guid>
				<description></description>
			</item>
			<item>
				<title>设计模式与MVC架构详解&#34;</title>
				<link>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/python%E5%B7%A5%E5%8E%82%E6%A8%A1%E5%BC%8F/</link>
				<pubDate>Thu, 06 Sep 2018 10:34:03 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F/python%E5%B7%A5%E5%8E%82%E6%A8%A1%E5%BC%8F/</guid>
				<description></description>
			</item>
			<item>
				<title>Python单例</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python%E5%8D%95%E4%BE%8B/</link>
				<pubDate>Wed, 05 Sep 2018 10:32:39 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python%E5%8D%95%E4%BE%8B/</guid>
				<description></description>
			</item>
			<item>
				<title>Python多态</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python%E5%A4%9A%E6%80%81/</link>
				<pubDate>Tue, 04 Sep 2018 10:32:01 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python%E5%A4%9A%E6%80%81/</guid>
				<description></description>
			</item>
			<item>
				<title>Python基础</title>
				<link>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python%E5%9F%BA%E7%A1%80/</link>
				<pubDate>Sun, 03 Jun 2018 10:22:36 +0800</pubDate>
				<guid>https://sunnnnner.github.io/posts/python/%E5%9F%BA%E7%A1%80/python%E5%9F%BA%E7%A1%80/</guid>
				<description></description>
			</item>
	</channel>
</rss>
