楼主: 宽客老丁
3699 35

[其他] The Python Library Reference [推广有奖]

  • 5关注
  • 6粉丝

已卖:86份资源

讲师

62%

还不是VIP/贵宾

-

威望
0
论坛币
311058 个
通用积分
384.9155
学术水平
8562 点
热心指数
8575 点
信用等级
8563 点
经验
403814 点
帖子
550
精华
0
在线时间
301 小时
注册时间
2018-12-30
最后登录
2026-1-30

楼主
宽客老丁 发表于 2021-12-13 20:57:26 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
len(s)
返回对象的长度(元素个数)。实参可以是序列(如 string、bytes、tuple、list 或 range 等)或集合(如
dictionary、set 或 frozen set 等)。
CPython implementation detail: len 对于大于sys.maxsize 的长度如range(2 ** 100) 会引
发OverflowError。
class list([iterable ])
虽然被称为函数,list 实际上是一种可变序列类型,详情请参阅列表 和序列类型 --- list, tuple,
range。
locals()
更新并返回表示当前本地符号表的字典。在函数代码块但不是类代码块中调用locals() 时将返
回自由变量。请注意在模块层级上,locals() 和globals() 是同一个字典。
注解: 不要更改此字典的内容;更改不会影响解释器使用的局部变量或自由变量的值。
map(function, iterable, ...)
返回一个将 function 应用于 iterable 中每一项并输出其结果的迭代器。如果传入了额外的 iterable 参
数,function 必须接受相同个数的实参并被应用于从所有可迭代对象中并行获取的项。当有多个可
迭代对象时,最短的可迭代对象耗尽则整个迭代就将结束。对于函数的输入已经是参数元组的情
况,请参阅itertools.starmap()。
max(iterable, *[, key, default])
max(arg1, arg2, *args[, key ])
返回可迭代对象中最大的元素,或者返回两个及以上实参中最大的。
如果只提供了一个位置参数,它必须是非空iterable,返回可迭代对象中最大的元素;如果提供了两
个及以上的位置参数,则返回最大的位置参数。
有两个可选只能用关键字的实参。key 实参指定排序函数用的参数,如传给list.sort() 的。
default 实参是当可迭代对象为空时返回的值。如果可迭代对象为空,并且没有给 default ,则会触
发ValueError。
如 果 有 多 个 最 大 元 素, 则 此 函 数 将 返 回 第 一 个 找 到 的。 这 和 其 他 稳 定 排 序 工
具 如 sorted(iterable, key=keyfunc, reverse=True)[0] 和 heapq.nlargest(1,
iterable, key=keyfunc) 保持一致。
3.4 新版功能: keyword-only 实参 default 。 在 3.8 版更改: key 可以为 None。
class memoryview(obj)
返回由给定实参创建的“内存视图”对象。有关详细信息,请参阅内存视图。
min(iterable, *[, key, default])
min(arg1, arg2, *args[, key ])
返回可迭代对象中最小的元素,或者返回两个及以上实参中最小的。
如果只提供了一个位置参数,它必须是iterable,返回可迭代对象中最小的元素;如果提供了两个及
以上的位置参数,则返回最小的位置参数。
有两个可选只能用关键字的实参。key 实参指定排序函数用的参数,如传给list.sort() 的。
default 实参是当可迭代对象为空时返回的值。如果可迭代对象为空,并且没有给 default ,则会触
发ValueError。
如 果 有 多 个 最 小 元 素, 则 此 函 数 将 返 回 第 一 个 找 到 的。 这 和 其 他 稳 定 排 序
工 具 如 sorted(iterable, key=keyfunc)[0] 和 heapq.nsmallest(1, iterable,
key=keyfunc) 保持一致。

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Reference Library python erence BRARY

已有 1 人评分学术水平 收起 理由
kongqingbao280 + 5 精彩帖子

总评分: 学术水平 + 5   查看全部评分

Don't just fly, soar.

沙发
宽客老丁 发表于 2021-12-13 21:04:19
ContentHandler 对象
Users are expected to subclass ContentHandler to support their application. The following methods are called
by the parser on the appropriate events in the input document:
ContentHandler.setDocumentLocator(locator)
Called by the parser to give the application a locator for locating the origin of document events.
SAX parsers are strongly encouraged (though not absolutely required) to supply a locator: if it does so, it must
supply the locator to the application by invoking this method before invoking any of the other methods in the
DocumentHandler interface.
The locator allows the application to determine the end position of any document-related event, even if the
parser is not reporting an error. Typically, the application will use this information for reporting its own errors
(such as character content that does not match an application’s business rules). The information returned by
the locator is probably not sufficient for use with a search engine.
Note that the locator will return correct information only during the invocation of the events in this interface.
The application should not attempt to use it at any other time.
ContentHandler.startDocument()
Receive notification of the beginning of a document.
The SAX parser will invoke this method only once, before any other methods in this interface or in DTDHandler
(except for setDocumentLocator()).
ContentHandler.endDocument()
Receive notification of the end of a document.
The SAX parser will invoke this method only once, and it will be the last method invoked during the parse.
The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable
error) or reached the end of input.
ContentHandler.startPrefixMapping(prefix, uri)
Begin the scope of a prefix-URI Namespace mapping.
The information from this event is not necessary for normal Namespace processing: the SAX XML reader will
automatically replace prefixes for element and attribute names when the feature_namespaces feature is
enabled (the default).
There are cases, however, when applications need to use prefixes in character data or in attribute
values, where they cannot safely be expanded automatically; the startPrefixMapping() and
endPrefixMapping() events supply the information to the application to expand prefixes in those contexts itself, if necessary.
Note that startPrefixMapping() and endPrefixMapping() events are not guaranteed to be properly nested relative to each-other: all startPrefixMapping() events will occur before the corresponding startElement() event, and all endPrefixMapping() events will occur after the corresponding
endElement() event, but their order is not guaranteed.
ContentHandler.endPrefixMapping(prefix)
End the scope of a prefix-URI mapping.
See startPrefixMapping() for details. This event will always occur after the corresponding
endElement() event, but the order of endPrefixMapping() events is not otherwise guaranteed.
ContentHandler.startElement(name, attrs)
Signals the start of an element in non-namespace mode

藤椅
宽客老丁 发表于 2021-12-13 21:04:34
DTDHandler 对象
DTDHandler instances provide the following methods:
DTDHandler.notationDecl(name, publicId, systemId)
Handle a notation declaration event.
DTDHandler.unparsedEntityDecl(name, publicId, systemId, ndata)
Handle an unparsed entity declaration event.

板凳
宽客老丁 发表于 2021-12-13 21:04:46
EntityResolver 对象
EntityResolver.resolveEntity(publicId, systemId)
Resolve the system identifier of an entity and return either the system identifier to read from as a string, or an
InputSource to read from. The default implementation returns systemId.

报纸
宽客老丁 发表于 2021-12-13 21:04:57
ErrorHandler 对象
Objects with this interface are used to receive error and warning information from the XMLReader. If you create an
object that implements this interface, then register the object with your XMLReader, the parser will call the methods
in your object to report all warnings and errors. There are three levels of errors available: warnings, (possibly)
recoverable errors, and unrecoverable errors. All methods take a SAXParseException as the only parameter.
Errors and warnings may be converted to an exception by raising the passed-in exception object.
ErrorHandler.error(exception)
Called when the parser encounters a recoverable error. If this method does not raise an exception, parsing may
continue, but further document information should not be expected by the application. Allowing the parser to
continue may allow additional errors to be discovered in the input document.
ErrorHandler.fatalError(exception)
Called when the parser encounters an error it cannot recover from; parsing is expected to terminate when this
method returns.
ErrorHandler.warning(exception)
Called when the parser presents minor warning information to the application. Parsing is expected to continue
when this method returns, and document information will continue to be passed to the application. Raising an
exception in this method will cause parsing to end.

地板
森陌夏栀 发表于 2021-12-13 22:17:52 来自手机
宽客老丁 发表于 2021-12-13 20:57
len(s)
返回对象的长度(元素个数)。实参可以是序列(如 string、bytes、tuple、list 或 range 等)或集合 ...
很好

7
三重虫 发表于 2021-12-15 18:33:18

8
数据洞见 发表于 2021-12-17 08:57:47
next(iterator[, default])
通过调用 iterator 的__next__() 方法获取下一个元素。如果迭代器耗尽,则返回给定的 default,
如果没有默认值则触发StopIteration。
class object
返回一个没有特征的新对象。object 是所有类的基类。它具有所有 Python 类实例的通用方法。这
个函数不接受任何实参。
注解: 由于object 没有__dict__,因此无法将任意属性赋给object 的实例。

9
数据洞见 发表于 2021-12-17 08:58:04
open(file, mode=’r’, buffering=-1, encoding=None, errors=None, newline=None, closefd=True,
opener=None)
打开 file 并返回对应的file object。如果该文件不能被打开,则引发OSError。请参阅 tut-files 获取此
函数的更多用法示例。
file 是一个path-like object,表示将要打开的文件的路径(绝对路径或者当前工作目录的相对路径),
也可以是要被封装的整数类型文件描述符。(如果是文件描述符,它会随着返回的 I/O 对象关闭而
关闭,除非 closefd 被设为 False 。)
mode 是一个可选字符串,用于指定打开文件的模式。默认值是 'r' ,这意味着它以文本模式
打开并读取。其他常见模式有:写入 'w' (截断已经存在的文件);排它性创建 'x' ;追加
写 'a' (在 一些 Unix 系统上,无论当前的文件指针在什么位置,所有写入都会追加到文件
末尾)。在文本模式,如果 encoding 没有指定,则根据平台来决定使用的编码:使用 locale.
getpreferredencoding(False) 来获取本地编码。

10
数据洞见 发表于 2021-12-17 08:58:24

pow(base, exp[, mod ])
返回 base 的 exp 次幂;如果 mod 存在,则返回 base 的 exp 次幂对 mod 取余(比 pow(base, exp)
% mod 更高效)。两参数形式 pow(base, exp) 等价于乘方运算符: base**exp。
参数必须具有数值类型。对于混用的操作数类型,则将应用双目算术运算符的类型强制转换规则。
对于int 操作数,结果具有与操作数相同的类型(强制转换后),除非第二个参数为负值;在这种
情况下,所有参数将被转换为浮点数并输出浮点数结果。例如,10**2 返回 100,但 10**-2 返 回 0.01。
对于int 操作数 base 和 exp,如果给出 mod,则 mod 必须为整数类型并且 mod 必须不为零。如果给出
mod 并且 exp 为负值,则 base 必须相对于 mod 不可整除。在这种情况下,将会返回 pow(inv_base,
-exp, mod),其中 inv_base 为 base 的倒数对 mod 取余。
已有 1 人评分经验 论坛币 收起 理由
yunnandlg + 100 + 100 精彩帖子

总评分: 经验 + 100  论坛币 + 100   查看全部评分

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-31 12:01