内置类型— Python 3.15.2 文档
有些操作受多种对象类型的支持;特别地,实际上所有对象都可以比较是否相等、检测逻辑值,以及转换为字符串(使用 repr() 函数或略有差异的 str() 函数)。后一个函数是在 ...
有些操作受多种对象类型的支持;特别地,实际上所有对象都可以比较是否相等、检测逻辑值,以及转换为字符串(使用 repr() 函数或略有差异的 str() 函数)。后一个函数是在 ...
Textual data in Python is handled with str objects, or strings. Strings are immutable sequences of Unicode code points.
1 day ago · This module defines an object type which can compactly represent an array of basic values: characters, integers, floating-point numbers, complex numbers. Arrays are mutable sequence types and behav...
Aug 3, 2020 ... 标准库模块所要求的编码风格记录于PEP 8 之中。 语言核心内容¶. 变量明明有值,为什么还会出现UnboundLocalError?¶. 因为在函数内部 ...
It helps to have a Python interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well. For a description of standard objects and modules, see Python built-ins reference and The Python standard library.
CPython implementation detail: The internal buffer of PyByteArrayObject always includes an extra trailing null byte for compatibility with null terminated C strings. This extra byte is not counted in PyByteArray_Size() nor in the len arguments of the functions below.
1 day ago · The array module provides an array object that is like a list that stores only homogeneous data and stores it more compactly. The following example shows an array of numbers stored as two byte unsigned binary numbers (typecode "H") rather than the usual 16 bytes per entry for regular lists of Python int objects:
's' is an alias for 'b' and should only be used for Python2/3 code bases. ... 3, 4, 5]) >>> b = array.array('d', [1.0, 2.0, 3.0, 4.0, 5.0]) >>> c = array ...
For code that cannot use the lazy keyword directly (for example, when supporting Python versions older than 3.15 while still using lazy imports on 3.15+), a module can define __lazy_modules__ as a container of fully qualified module name strings.
2 days ago · The optional source parameter can be used to initialize the array in a few different ways: If it is a string, you must also give the encoding (and optionally, errors) parameters; bytearray () then converts the string to bytes using str.encode (). If it is an integer, the array will have that size and will be initialized with null bytes.
シーケンス型 --- list , tuple , range ¶. 基本的なシーケンス型は 3 つあります: リスト、タプル、range オブジェクトです。バイナリデータ や テキスト文字列 ...
1 day ago · The string type has some methods that perform useful operations for padding strings to a given column width. When you don’t need fancy output but just want a quick display of some variables for debugging purposes, you can convert any value to a string with the repr () or str () functions.
Sep 3, 2025 ... ... 3, 4, 5]) >>> b = array.array('d', [1.0, 2.0, 3.0, 4.0, 5.0]) >>> c ... For example, the following code is discouraged, but will run without ...
1 day ago · The Python parser strips indentation from multi-line string literals when they serve as module, class, or function docstrings. Here is an example of a multi-line docstring: