<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>skypiea - python</title>
    <link>https://skypiea.top/forum.php?mod=forumdisplay&amp;fid=18</link>
    <description>Latest 20 threads of python</description>
    <copyright>Copyright(C) skypiea</copyright>
    <generator>Discuz! Board by Comsenz Inc.</generator>
    <lastBuildDate>Tue, 12 May 2026 12:32:49 +0000</lastBuildDate>
    <ttl>60</ttl>
    <image>
      <url>https://skypiea.top/static/image/common/logo_88_31.gif</url>
      <title>skypiea</title>
      <link>https://skypiea.top/</link>
    </image>
    <item>
      <title>[pandas]dataframe不打印表头和索引</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=1440</link>
      <description><![CDATA[]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 11 May 2026 03:32:06 +0000</pubDate>
    </item>
    <item>
      <title>类</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=1431</link>
      <description><![CDATA[类提供了把数据和功能绑定在一起的方法。创建新类时创建了新的对象 类型，从而能够创建该类型的新 实例。实例具有能维持自身状态的属性，还具有能修改自身状态的方法（由其所属的类来定义）。

和其他编程语言相比，Python 的类只使用了很少的新语法和语义。Python 的类 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Tue, 21 Apr 2026 09:19:01 +0000</pubDate>
    </item>
    <item>
      <title>错误和异常</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=1430</link>
      <description><![CDATA[错误可（至少）被分为两种：语法错误 和 异常。

1. 语法错误
语法错误又称解析错误，是学习 Python 时最常见的错误：

while True print(\'Hello world\')
  File \&quot;\&quot;, line 1
    while True print(\'Hello world\')
               ^^^^^
SyntaxError: invalid syntax
解 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Tue, 21 Apr 2026 08:46:20 +0000</pubDate>
    </item>
    <item>
      <title>读写文件</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=1429</link>
      <description><![CDATA[open() 返回一个 file object ，最常使用的是两个位置参数和一个关键字参数：open(filename, mode, encoding=None)

f = open(\'workfile\', \'w\', encoding=\&quot;utf-8\&quot;)
第一个实参是文件名字符串。第二个实参是包含描述文件使用方式字符的字符串。mode 的值包括 \'r\' ，表示 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Tue, 21 Apr 2026 08:28:46 +0000</pubDate>
    </item>
    <item>
      <title>输入与输出 输出格式</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=1213</link>
      <description><![CDATA[到目前为止我们已遇到过两种写入值的方式: 表达式语句 和 print() 函数。 （第三种方式是使用文件对象的 write() 方法；标准输出文件可以被引用为 sys.stdout。 更多相关信息请参阅标准库参考）。

对输出格式的控制不只是打印空格分隔的值，还需要更多方式。格式化输出 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Tue, 21 Apr 2026 01:20:21 +0000</pubDate>
    </item>
    <item>
      <title>包</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=1211</link>
      <description><![CDATA[包是通过使用“带点号模块名”来构造 Python 模块命名空间的一种方式。 例如，模块名 A.B 表示名为 A 的包中名为 B 的子模块。 就像使用模块可以让不同模块的作者不必担心彼此的全局变量名一样，使用带点号模块名也可以让 NumPy 或 Pillow 等多模块包的作者也不必担心彼 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Tue, 21 Apr 2026 01:18:05 +0000</pubDate>
    </item>
    <item>
      <title>dir() 函数</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=1208</link>
      <description><![CDATA[内置函数 dir() 用于查找模块定义的名称。返回结果是经过排序的字符串列表：

import fibo, sys
dir(fibo)
[\'__name__\', \'fib\', \'fib2\']
dir(sys)
[\'__breakpointhook__\', \'__displayhook__\', \'__doc__\', \'__excepthook__\',
 \'__interactivehook__\', \'__loader__\', \'__n ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Tue, 21 Apr 2026 01:11:35 +0000</pubDate>
    </item>
    <item>
      <title>标准模块</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=1195</link>
      <description><![CDATA[Python 自带一个标准模块的库，它在 Python 库参考（此处以下称为\&quot;库参考\&quot; ）里另外描述。 一些模块是内嵌到解释器里面的， 它们给一些虽并非语言核心但却内嵌的操作提供接口，要么是为了效率，要么是给操作系统基础操作例如系统调用提供接口。 这些模块集是一个配置选 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Tue, 21 Apr 2026 00:51:42 +0000</pubDate>
    </item>
    <item>
      <title>模块</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=899</link>
      <description><![CDATA[退出 Python 解释器后，再次进入时，之前在 Python 解释器中定义的函数和变量就丢失了。因此，编写较长程序时，最好用文本编辑器代替解释器，执行文件中的输入内容，这就是编写 脚本 。随着程序越来越长，为了方便维护，最好把脚本拆分成多个文件。编写脚本还有一个好处 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 10:21:13 +0000</pubDate>
    </item>
    <item>
      <title>序列和其他类型的比较</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=825</link>
      <description><![CDATA[序列对象可以与相同序列类型的其他对象比较。这种比较使用 字典式 顺序：首先，比较前两个对应元素，如果不相等，则可确定比较结果；如果相等，则比较之后的两个元素，以此类推，直到其中一个序列结束。如果要比较的两个元素本身是相同类型的序列，则递归地执行字典式顺 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 09:18:34 +0000</pubDate>
    </item>
    <item>
      <title>深入条件控制</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=815</link>
      <description><![CDATA[while 和 if 条件句不只可以进行比较，还可以使用任意运算符。

比较运算符 in 和 not in 用于执行确定一个值是否存在（或不存在）于某个容器中的成员检测。 运算符 is 和 is not 用于比较两个对象是否是同一个对象。 所有比较运算符的优先级都一样，且低于任何数值运算 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 09:04:47 +0000</pubDate>
    </item>
    <item>
      <title>循环的技巧</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=814</link>
      <description><![CDATA[当对字典执行循环时，可以使用 items() 方法同时提取键及其对应的值。

knights = {\'gallahad\': \'the pure\', \'robin\': \'the brave\'}
for k, v in knights.items():
    print(k, v)

gallahad the pure
robin the brave
在序列中循环时，用 enumerate() 函数可以同时取 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 09:01:23 +0000</pubDate>
    </item>
    <item>
      <title>字典</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=810</link>
      <description><![CDATA[另一个常用的 Python 内置数据类型是 字典 (参见 映射类型 --- dict)。 字典在其他编程语言中可能称为“联合内存”或“联合数组”。 与以连续整数为索引的序列不同，字典是以 键 来索引的，键可以是任何不可变类型；字符串和数字总是可以作为键。 元组在其仅包含字符串 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 08:56:40 +0000</pubDate>
    </item>
    <item>
      <title>集合</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=797</link>
      <description><![CDATA[Python 还包括一个表示 集合 的数据类型。 集合是由不重复元素组成的无序多项集。 基本用法包括成员检测和消除重复元素。 集合对象还支持合集、交集、差集和对称差集等数学运算。

创建集合用花括号或 set() 函数。注意，创建空集合只能用 set()，不能用 {}，{} 创建的 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 08:48:02 +0000</pubDate>
    </item>
    <item>
      <title>元组和序列</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=788</link>
      <description><![CDATA[列表和字符串有很多共性，例如，索引和切片操作。这两种数据类型是 序列 （参见 序列类型 --- list, tuple, range）。随着 Python 语言的发展，其他的序列类型也被加入其中。本节介绍另一种标准序列类型：元组。

元组由多个用逗号隔开的值组成，例如：

t = 12345, 543 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 08:42:26 +0000</pubDate>
    </item>
    <item>
      <title>del 语句</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=786</link>
      <description><![CDATA[可以按索引而不是按值从一个列表移除条目：即使用 del 语句。 这不同于返回一个值的 pop() 方法。 del 语句还可被用来从列表移除切片或清空整个列表（之前我们通过将一个空列表赋值给切片实现此功能）。 例如:

a = [-1, 1, 66.25, 333, 333, 1234.5]
del a[0]
a
[1, 66 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 08:40:55 +0000</pubDate>
    </item>
    <item>
      <title>列表</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=571</link>
      <description><![CDATA[列表 数据类型具有更多的方法。 下面是列表对象的所有方法：

list.append(value, /)
在列表末尾添加一项。 类似于 a[len(a):] = [x]。

list.extend(iterable, /)
通过添加来自 iterable 的所有项来扩展列表。 类似于 a[len(a):] = iterable。

list.insert(index, val ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 01:23:17 +0000</pubDate>
    </item>
    <item>
      <title>编码风格</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=568</link>
      <description><![CDATA[现在你即将编写更长、更复杂的 Python 代码段，是时候讨论一下 代码风格 了。 大多数语言都能被书写为（或更准确地说，是 被格式化 为）不同的风格；有些风格相比其他风格可读性更好。 能让别人轻松阅读你的代码总是一个好主意，而采用一种良好的代码风格对此会很有帮助 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Mon, 20 Apr 2026 01:21:12 +0000</pubDate>
    </item>
    <item>
      <title>函数定义详解</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=239</link>
      <description><![CDATA[函数定义支持可变数量的参数。这里列出三种可以组合使用的形式。

1. 默认值参数
为参数指定默认值是非常有用的方式。调用函数时，可以使用比定义时更少的参数，例如：

def ask_ok(prompt, retries=4, reminder=\'Please try again!\'):
    while True:
        reply = ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Wed, 15 Apr 2026 11:33:06 +0000</pubDate>
    </item>
    <item>
      <title>定义函数</title>
      <link>https://skypiea.top/forum.php?mod=viewthread&amp;tid=238</link>
      <description><![CDATA[下列代码创建一个可以输出限定数值内的斐波那契数列函数：

Copy
def fib(n):    # 打印小于 n 的斐波那契数列
    \&quot;\&quot;\&quot;Print a Fibonacci series less than n.\&quot;\&quot;\&quot;
    a, b = 0, 1
    while a &lt; n:
        print(a, end=\' \')
        a, b = b, a+b
    print()

# 现 ...]]></description>
      <category>python</category>
      <author>skypiea</author>
      <pubDate>Wed, 15 Apr 2026 11:29:55 +0000</pubDate>
    </item>
  </channel>
</rss>