<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0"><channel><title>分类：Python - GodOne</title><link>https://blog.godone.top/categories/Python</link><atom:link href="https://blog.godone.top/categories/Python/feed/categories/Python.xml" rel="self" type="application/rss+xml"/><description>GodOne</description><generator>Halo v2.27.1</generator><language>zh-cn</language><lastBuildDate>Mon, 16 Nov 2026 13:30:10 GMT</lastBuildDate><item><title><![CDATA[Python-运算]]></title><link>https://blog.godone.top/archives/%E8%BF%90%E7%AE%97</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E8%BF%90%E7%AE%97&amp;url=/archives/%E8%BF%90%E7%AE%97" width="1" height="1" alt="" style="opacity:0;">计算运算符 符号 说明 举例 + 加 10 + 10 = 20 - 减 20 - 10 = 10 *]]></description><guid isPermaLink="false">/archives/%E8%BF%90%E7%AE%97</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:03 GMT</pubDate></item><item><title><![CDATA[Python模块-sys模块]]></title><link>https://blog.godone.top/archives/sys%E6%A8%A1%E5%9D%97</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python%E6%A8%A1%E5%9D%97-sys%E6%A8%A1%E5%9D%97&amp;url=/archives/sys%E6%A8%A1%E5%9D%97" width="1" height="1" alt="" style="opacity:0;">sys模块是python中的一个用于操纵操作系统的模块 sys.argv sys.argv，用列接收命令行给py脚本的参数 def demo_01(num1=10, num2=3): # 默认值为10和3 print(num1 + num2) if __name__ == '__main__]]></description><guid isPermaLink="false">/archives/sys%E6%A8%A1%E5%9D%97</guid><dc:creator>GodOne</dc:creator><category>模块</category><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:03 GMT</pubDate></item><item><title><![CDATA[Python模块-string模块]]></title><link>https://blog.godone.top/archives/string%E6%A8%A1%E5%9D%97</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python%E6%A8%A1%E5%9D%97-string%E6%A8%A1%E5%9D%97&amp;url=/archives/string%E6%A8%A1%E5%9D%97" width="1" height="1" alt="" style="opacity:0;">]]></description><guid isPermaLink="false">/archives/string%E6%A8%A1%E5%9D%97</guid><dc:creator>GodOne</dc:creator><category>模块</category><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:03 GMT</pubDate></item><item><title><![CDATA[Python模块-shutil模块]]></title><link>https://blog.godone.top/archives/shutil%E6%A8%A1%E5%9D%97</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python%E6%A8%A1%E5%9D%97-shutil%E6%A8%A1%E5%9D%97&amp;url=/archives/shutil%E6%A8%A1%E5%9D%97" width="1" height="1" alt="" style="opacity:0;">shutil模块可以执行一些基础的shell命令，如复制、移动、删除、解压等 复制 复制文件 使用 shutil.copy可以复制一个文件，并且复制后的文件会继承源文件的权限 def demo1(): shutil.copy(src='/usr/bin/ls', dst='/tm]]></description><guid isPermaLink="false">/archives/shutil%E6%A8%A1%E5%9D%97</guid><dc:creator>GodOne</dc:creator><category>模块</category><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python文件操作-缓存区]]></title><link>https://blog.godone.top/archives/%E7%BC%93%E5%AD%98%E5%8C%BA</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C-%E7%BC%93%E5%AD%98%E5%8C%BA&amp;url=/archives/%E7%BC%93%E5%AD%98%E5%8C%BA" width="1" height="1" alt="" style="opacity:0;">当我们调用write方法来往文件内写入数据时，数据不会立刻存入文件内，而会先存入缓存区，只有调用close和flush等方法才会把缓存区内的数据写入文件内 flush方法 def demo_2(): fw = open('/tmp/123.txt', mode='w') fw.wri]]></description><guid isPermaLink="false">/archives/%E7%BC%93%E5%AD%98%E5%8C%BA</guid><dc:creator>GodOne</dc:creator><category>文件操作</category><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python文件操作-write写]]></title><link>https://blog.godone.top/archives/write%E5%86%99</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C-write%E5%86%99&amp;url=/archives/write%E5%86%99" width="1" height="1" alt="" style="opacity:0;">write方法 写文本字符串 def demo_1(): fw = open('/tmp/aaa.txt', mode='w') fw.write('Hello World !!!\n') fw.close() 写入多行 def demo_1(): fw = ope]]></description><guid isPermaLink="false">/archives/write%E5%86%99</guid><dc:creator>GodOne</dc:creator><category>文件操作</category><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python文件操作-with open]]></title><link>https://blog.godone.top/archives/with-open</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C-with%20open&amp;url=/archives/with-open" width="1" height="1" alt="" style="opacity:0;">with open 可以快捷的打开文件，并且不再需要手动关闭文件，简化了文件的操作 with open('/etc/password', mode='r') as fr: fr.readline()]]></description><guid isPermaLink="false">/archives/with-open</guid><dc:creator>GodOne</dc:creator><category>文件操作</category><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python文件操作-read读]]></title><link>https://blog.godone.top/archives/read%E8%AF%BB</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C-read%E8%AF%BB&amp;url=/archives/read%E8%AF%BB" width="1" height="1" alt="" style="opacity:0;">read方法 读取整个文件 def read1(): passwd = open('/etc/passwd', 'r') text = passwd.read() passwd.close() 读取指定个字符 读取文本时会随之移动读取指针，如果要重置指针可用 .close()方法]]></description><guid isPermaLink="false">/archives/read%E8%AF%BB</guid><dc:creator>GodOne</dc:creator><category>文件操作</category><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python-文件操作]]></title><link>https://blog.godone.top/archives/%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C-2</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C&amp;url=/archives/%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C-2" width="1" height="1" alt="" style="opacity:0;">基本语法 file_demo = open (file_name, mode = 'r') 参数： file_name：要打开的文件路径 mode：打开文件的方式 模式 操作 r 以只读的模式打开（如文件不存在会报错） w 以写的模式打开（如文件存在则会清空文件，不存在会创建文件） a 以追加的模式]]></description><guid isPermaLink="false">/archives/%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C-2</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python-数据类型转换]]></title><link>https://blog.godone.top/archives/%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2&amp;url=/archives/%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2" width="1" height="1" alt="" style="opacity:0;">查看数据类型 使用 type()可以查看数据的类型 type("12345") type(12345) 转换成 int(整数) 类型 使用 int() 即可将数据转换成 int类型 a = "12345" int(a) 转换成 str(字符串) 类型 使用 str() 即可将数据转换成 str类]]></description><guid isPermaLink="false">/archives/%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python-循环]]></title><link>https://blog.godone.top/archives/%E5%BE%AA%E7%8E%AF-2</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E5%BE%AA%E7%8E%AF&amp;url=/archives/%E5%BE%AA%E7%8E%AF-2" width="1" height="1" alt="" style="opacity:0;">While循环 执行语句可以是单个语句或语句块。判断条件可以是任何表达式，任何非零、或非空（null）的值均为true。 当判断条件假 false 时，循环结束。 执行流程图如下： break（跳出当前循环） def for_demo(): count = 0 while True:]]></description><guid isPermaLink="false">/archives/%E5%BE%AA%E7%8E%AF-2</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python-字符串截取与切片]]></title><link>https://blog.godone.top/archives/%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%88%AA%E5%8F%96%E4%B8%8E%E5%88%87%E7%89%87</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%88%AA%E5%8F%96%E4%B8%8E%E5%88%87%E7%89%87&amp;url=/archives/%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%88%AA%E5%8F%96%E4%B8%8E%E5%88%87%E7%89%87" width="1" height="1" alt="" style="opacity:0;">截取：str[下标] ## 截取时的下标从0开始 切片：str[start:end:step] ## 切片时不包含结尾 例如： ## 定义一个字符串变量： a = 'abcdef 123' ## 截取出字符串中的c print(a[2]) ## 计算字符串的长度 print(len(a)) #]]></description><guid isPermaLink="false">/archives/%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%88%AA%E5%8F%96%E4%B8%8E%E5%88%87%E7%89%87</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:02 GMT</pubDate></item><item><title><![CDATA[Python-字典]]></title><link>https://blog.godone.top/archives/%E5%AD%97%E5%85%B8</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E5%AD%97%E5%85%B8&amp;url=/archives/%E5%AD%97%E5%85%B8" width="1" height="1" alt="" style="opacity:0;">Python中字典是一个无序的、没有索引、没有切片、可变的数据类型可以存储多个不同类型的数值，又多个键值对组成 字典中的key是唯一的，不能重复，如有两个相同的key，后面的key的值会覆盖前面的key的值 ## 定义一个字典 dict01 = {'name': 'Alice', 'age': 25]]></description><guid isPermaLink="false">/archives/%E5%AD%97%E5%85%B8</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:01 GMT</pubDate></item><item><title><![CDATA[Python-基础]]></title><link>https://blog.godone.top/archives/%E5%9F%BA%E7%A1%80</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E5%9F%BA%E7%A1%80&amp;url=/archives/%E5%9F%BA%E7%A1%80" width="1" height="1" alt="" style="opacity:0;">end end参数可以指定结尾的字符,默认是换行符 print("Hello World!", end="") print("Hello Again", "I'm a Programmer") sep sep参数可以指定多个字符串之间的分隔符,默认是空格 print("Hello World!",]]></description><guid isPermaLink="false">/archives/%E5%9F%BA%E7%A1%80</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:01 GMT</pubDate></item><item><title><![CDATA[Python-列表]]></title><link>https://blog.godone.top/archives/%E5%88%97%E8%A1%A8</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E5%88%97%E8%A1%A8&amp;url=/archives/%E5%88%97%E8%A1%A8" width="1" height="1" alt="" style="opacity:0;">Python中的列表是一个有序的、有索引、有切片、可变的数据类型可以存储多个不同类型的数值 ## 定义一个列表 list01 = [1,2,"abc",[4,1]] ## 计算列表长度 print(len(list01)) ## 列表截取和切片 #截取 print(list01[3]) ## 切]]></description><guid isPermaLink="false">/archives/%E5%88%97%E8%A1%A8</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:01 GMT</pubDate></item><item><title><![CDATA[Python-函数]]></title><link>https://blog.godone.top/archives/%E5%87%BD%E6%95%B0-2</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E5%87%BD%E6%95%B0&amp;url=/archives/%E5%87%BD%E6%95%B0-2" width="1" height="1" alt="" style="opacity:0;">函数是组织好的，可重复使用的，用来实现单一，或相关联功能的代码段。 定义一个函数 你可以定义一个由自己想要功能的函数，以下是简单的规则： 函数代码块以 def 关键词开头，后接函数标识符名称和圆括号 () 。 任何传入参数和自变量必须放在圆括号中间。圆括号之间可以用于定义参数。 函数的第一行语句可以]]></description><guid isPermaLink="false">/archives/%E5%87%BD%E6%95%B0-2</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:01 GMT</pubDate></item><item><title><![CDATA[Python-元组]]></title><link>https://blog.godone.top/archives/%E5%85%83%E7%BB%84</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-%E5%85%83%E7%BB%84&amp;url=/archives/%E5%85%83%E7%BB%84" width="1" height="1" alt="" style="opacity:0;">Python中的元组是一个有序的、有索引、有切片、不可变的数据类型可以存储多个不同类型的数值 ## 定义一个元组 tuple01 = (1, 2, 3, "hello", [99, 100]) tuple01 = (1,) # 创建单个元素的元组时需要加上,号 ## 元组截取和切片 #截取]]></description><guid isPermaLink="false">/archives/%E5%85%83%E7%BB%84</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:01 GMT</pubDate></item><item><title><![CDATA[Python-range函数]]></title><link>https://blog.godone.top/archives/range%E5%87%BD%E6%95%B0</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-range%E5%87%BD%E6%95%B0&amp;url=/archives/range%E5%87%BD%E6%95%B0" width="1" height="1" alt="" style="opacity:0;">range() 返回的是一个可迭代对象（类型是对象），而不是列表类型 函数语法 range(start, stop[, step]) 参数说明： start: 计数从 start 开始。默认是从 0 开始。例如range（5）等价于range（0， 5）; stop: 计数到 stop 结束，但不包]]></description><guid isPermaLink="false">/archives/range%E5%87%BD%E6%95%B0</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:01 GMT</pubDate></item><item><title><![CDATA[Python-if判断]]></title><link>https://blog.godone.top/archives/if%E5%88%A4%E6%96%AD</link><description><![CDATA[<img src="https://blog.godone.top/plugins/feed/assets/telemetry.gif?title=Python-if%E5%88%A4%E6%96%AD&amp;url=/archives/if%E5%88%A4%E6%96%AD" width="1" height="1" alt="" style="opacity:0;">if判断语句是通过一条或多条语句的执行结果（True或者False）来决定执行的代码块。 可以通过下图来简单了解条件语句的执行过程: if 语句的判断条件可以用&gt;（大于）、&lt;(小于)、==（等于）、&gt;=（大于等于）、&lt;=（小于等于）来表示其关系。 当判断条件为多个值时，可以使用以下形式： if 判断]]></description><guid isPermaLink="false">/archives/if%E5%88%A4%E6%96%AD</guid><dc:creator>GodOne</dc:creator><category>Python</category><pubDate>Sun, 1 Nov 2026 17:12:01 GMT</pubDate></item></channel></rss>