python共有26个内置类,你知道几个?

目录

数值类 4

int

bool

float

complex

序列类 5

str

tuple

list

bytes

bytearray

字典和集合 3

dict

set

frozenset

其他可迭代类 5

range

enumerate

slice

reversed

zip

映射和筛选 2

map

filter

类型和视图 2

type

memoryview

类相关类型 5

object

super

property

classmethod

staticmethod

小结


Python内置了多种类型的数据结构和其他功能相关的类。这些内置类大致可以分为几类:数值类型、序列类型、字典集合类型、映射筛选类型、其他内置类型等。分类说明如下:

数值类 4

int

整数类型,用于表示整数值。

class int(object)

int([x]) -> integer
int(x, base=10) -> integer

Convert a number or string to an integer, or return 0 if no arguments
are given.  If x is a number, return x.__int__().  For floating point
numbers, this truncates towards zero.

If x is not a number or if base is given, then x must be a string,
bytes, or bytearray instance representing an integer literal in the
given base.  The literal can be preceded by '+' or '-' and be surrounded
by whitespace.  The base defaults to 10.  Valid bases are 0 and 2-36.
Base 0 means to interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4

Built-in subclasses:
    bool

Methods defined here:

__abs__(self, /)
    abs(self)

__add__(self, value, /)
    Return self+value.

__and__(self, value, /)
    Return self&value.

__bool__(self, /)
    True if self else False

__ceil__(...)
    Ceiling of an Integral returns itself.

__divmod__(self, value, /)
    Return divmod(self, value).

__eq__(self, value, /)
    Return self==value.

__float__(self, /)
    float(self)

__floor__(...)
    Flooring an Integral returns itself.

__floordiv__(self, value, /)
    Return self//value.

__format__(self, format_spec, /)
    Convert to a string according to format_spec.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getnewargs__(self, /)

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__index__(self, /)
    Return self converted to an integer, if self is suitable for use as an index into a list.

__int__(self, /)
    int(self)

__invert__(self, /)
    ~self

__le__(self, value, /)
    Return self<=value.

__lshift__(self, value, /)
    Return self<<value.

__lt__(self, value, /)
    Return self<value.

__mod__(self, value, /)
    Return self%value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__neg__(self, /)
    -self

__or__(self, value, /)
    Return self|value.

__pos__(self, /)
    +self

__pow__(self, value, mod=None, /)
    Return pow(self, value, mod).

__radd__(self, value, /)
    Return value+self.

__rand__(self, value, /)
    Return value&self.

__rdivmod__(self, value, /)
    Return divmod(value, self).

__repr__(self, /)
    Return repr(self).

__rfloordiv__(self, value, /)
    Return value//self.

__rlshift__(self, value, /)
    Return value<<self.

__rmod__(self, value, /)
    Return value%self.

__rmul__(self, value, /)
    Return value*self.

__ror__(self, value, /)
    Return value|self.

__round__(...)
    Rounding an Integral returns itself.

    Rounding with an ndigits argument also returns an integer.

__rpow__(self, value, mod=None, /)
    Return pow(value, self, mod).

__rrshift__(self, value, /)
    Return value>>self.

__rshift__(self, value, /)
    Return self>>value.

__rsub__(self, value, /)
    Return value-self.

__rtruediv__(self, value, /)
    Return value/self.

__rxor__(self, value, /)
    Return value^self.

__sizeof__(self, /)
    Returns size in memory, in bytes.

__sub__(self, value, /)
    Return self-value.

__truediv__(self, value, /)
    Return self/value.

__trunc__(...)
    Truncating an Integral returns itself.

__xor__(self, value, /)
    Return self^value.

as_integer_ratio(self, /)
    Return a pair of integers, whose ratio is equal to the original int.

    The ratio is in lowest terms and has a positive denominator.

    >>> (10).as_integer_ratio()
    (10, 1)
    >>> (-10).as_integer_ratio()
    (-10, 1)
    >>> (0).as_integer_ratio()
    (0, 1)

bit_count(self, /)
    Number of ones in the binary representation of the absolute value of self.

    Also known as the population count.

    >>> bin(13)
    '0b1101'
    >>> (13).bit_count()
    3

bit_length(self, /)
    Number of bits necessary to represent self in binary.

    >>> bin(37)
    '0b100101'
    >>> (37).bit_length()
    6

conjugate(...)
    Returns self, the complex conjugate of any int.

is_integer(self, /)
    Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(self, /, length=1, byteorder='big', *, signed=False)
    Return an array of bytes representing an integer.

    length
      Length of bytes object to use.  An OverflowError is raised if the
      integer is not representable with the given number of bytes.  Default
      is length 1.
    byteorder
      The byte order used to represent the integer.  If byteorder is 'big',
      the most significant byte is at the beginning of the byte array.  If
      byteorder is 'little', the most significant byte is at the end of the
      byte array.  To request the native byte order of the host system, use
      `sys.byteorder' as the byte order value.  Default is to use 'big'.
    signed
      Determines whether two's complement is used to represent the integer.
      If signed is False and a negative integer is given, an OverflowError
      is raised.

----------------------------------------------------------------------
Class methods defined here:

from_bytes(bytes, byteorder='big', *, signed=False) from type
    Return the integer represented by the given array of bytes.

    bytes
      Holds the array of bytes to convert.  The argument must either
      support the buffer protocol or be an iterable object producing bytes.
      Bytes and bytearray are examples of built-in objects that support the
      buffer protocol.
    byteorder
      The byte order used to represent the integer.  If byteorder is 'big',
      the most significant byte is at the beginning of the byte array.  If
      byteorder is 'little', the most significant byte is at the end of the
      byte array.  To request the native byte order of the host system, use
      `sys.byteorder' as the byte order value.  Default is to use 'big'.
    signed
      Indicates whether two's complement is used to represent the integer.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

denominator
    the denominator of a rational number in lowest terms

imag
    the imaginary part of a complex number

numerator
    the numerator of a rational number in lowest terms

real
    the real part of a complex number

x = 10  
print(type(x))  # 输出: <class 'int'>

bool

布尔类型,有两个值:True 和 False。它是int的子类,其中True相当于1,False相当于0。

class bool(int)

bool(x) -> bool

Returns True when the argument x is true, False otherwise.
The builtins True and False are the only two instances of the class bool.
The class bool is a subclass of the class int, and cannot be subclassed.

Method resolution order:
    bool
    int
    object

Methods defined here:

__and__(self, value, /)
    Return self&value.

__invert__(self, /)
    ~self

__or__(self, value, /)
    Return self|value.

__rand__(self, value, /)
    Return value&self.

__repr__(self, /)
    Return repr(self).

__ror__(self, value, /)
    Return value|self.

__rxor__(self, value, /)
    Return value^self.

__xor__(self, value, /)
    Return self^value.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Methods inherited from int:

__abs__(self, /)
    abs(self)

__add__(self, value, /)
    Return self+value.

__bool__(self, /)
    True if self else False

__ceil__(...)
    Ceiling of an Integral returns itself.

__divmod__(self, value, /)
    Return divmod(self, value).

__eq__(self, value, /)
    Return self==value.

__float__(self, /)
    float(self)

__floor__(...)
    Flooring an Integral returns itself.

__floordiv__(self, value, /)
    Return self//value.

__format__(self, format_spec, /)
    Convert to a string according to format_spec.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getnewargs__(self, /)

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__index__(self, /)
    Return self converted to an integer, if self is suitable for use as an index into a list.

__int__(self, /)
    int(self)

__le__(self, value, /)
    Return self<=value.

__lshift__(self, value, /)
    Return self<<value.

__lt__(self, value, /)
    Return self<value.

__mod__(self, value, /)
    Return self%value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__neg__(self, /)
    -self

__pos__(self, /)
    +self

__pow__(self, value, mod=None, /)
    Return pow(self, value, mod).

__radd__(self, value, /)
    Return value+self.

__rdivmod__(self, value, /)
    Return divmod(value, self).

__rfloordiv__(self, value, /)
    Return value//self.

__rlshift__(self, value, /)
    Return value<<self.

__rmod__(self, value, /)
    Return value%self.

__rmul__(self, value, /)
    Return value*self.

__round__(...)
    Rounding an Integral returns itself.

    Rounding with an ndigits argument also returns an integer.

__rpow__(self, value, mod=None, /)
    Return pow(value, self, mod).

__rrshift__(self, value, /)
    Return value>>self.

__rshift__(self, value, /)
    Return self>>value.

__rsub__(self, value, /)
    Return value-self.

__rtruediv__(self, value, /)
    Return value/self.

__sizeof__(self, /)
    Returns size in memory, in bytes.

__sub__(self, value, /)
    Return self-value.

__truediv__(self, value, /)
    Return self/value.

__trunc__(...)
    Truncating an Integral returns itself.

as_integer_ratio(self, /)
    Return a pair of integers, whose ratio is equal to the original int.

    The ratio is in lowest terms and has a positive denominator.

    >>> (10).as_integer_ratio()
    (10, 1)
    >>> (-10).as_integer_ratio()
    (-10, 1)
    >>> (0).as_integer_ratio()
    (0, 1)

bit_count(self, /)
    Number of ones in the binary representation of the absolute value of self.

    Also known as the population count.

    >>> bin(13)
    '0b1101'
    >>> (13).bit_count()
    3

bit_length(self, /)
    Number of bits necessary to represent self in binary.

    >>> bin(37)
    '0b100101'
    >>> (37).bit_length()
    6

conjugate(...)
    Returns self, the complex conjugate of any int.

is_integer(self, /)
    Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(self, /, length=1, byteorder='big', *, signed=False)
    Return an array of bytes representing an integer.

    length
      Length of bytes object to use.  An OverflowError is raised if the
      integer is not representable with the given number of bytes.  Default
      is length 1.
    byteorder
      The byte order used to represent the integer.  If byteorder is 'big',
      the most significant byte is at the beginning of the byte array.  If
      byteorder is 'little', the most significant byte is at the end of the
      byte array.  To request the native byte order of the host system, use
      `sys.byteorder' as the byte order value.  Default is to use 'big'.
    signed
      Determines whether two's complement is used to represent the integer.
      If signed is False and a negative integer is given, an OverflowError
      is raised.

----------------------------------------------------------------------
Class methods inherited from int:

from_bytes(bytes, byteorder='big', *, signed=False) from type
    Return the integer represented by the given array of bytes.

    bytes
      Holds the array of bytes to convert.  The argument must either
      support the buffer protocol or be an iterable object producing bytes.
      Bytes and bytearray are examples of built-in objects that support the
      buffer protocol.
    byteorder
      The byte order used to represent the integer.  If byteorder is 'big',
      the most significant byte is at the beginning of the byte array.  If
      byteorder is 'little', the most significant byte is at the end of the
      byte array.  To request the native byte order of the host system, use
      `sys.byteorder' as the byte order value.  Default is to use 'big'.
    signed
      Indicates whether two's complement is used to represent the integer.

----------------------------------------------------------------------
Data descriptors inherited from int:

denominator
    the denominator of a rational number in lowest terms

imag
    the imaginary part of a complex number

numerator
    the numerator of a rational number in lowest terms

real
    the real part of a complex number

is_true = True  
print(type(is_true))  # 输出: <class 'bool'>

float

浮点数类型,用于表示实数值。

class float(object)

float(x=0, /)

Convert a string or number to a floating point number, if possible.

Methods defined here:

__abs__(self, /)
    abs(self)

__add__(self, value, /)
    Return self+value.

__bool__(self, /)
    True if self else False

__ceil__(self, /)
    Return the ceiling as an Integral.

__divmod__(self, value, /)
    Return divmod(self, value).

__eq__(self, value, /)
    Return self==value.

__float__(self, /)
    float(self)

__floor__(self, /)
    Return the floor as an Integral.

__floordiv__(self, value, /)
    Return self//value.

__format__(self, format_spec, /)
    Formats the float according to format_spec.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getnewargs__(self, /)

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__int__(self, /)
    int(self)

__le__(self, value, /)
    Return self<=value.

__lt__(self, value, /)
    Return self<value.

__mod__(self, value, /)
    Return self%value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__neg__(self, /)
    -self

__pos__(self, /)
    +self

__pow__(self, value, mod=None, /)
    Return pow(self, value, mod).

__radd__(self, value, /)
    Return value+self.

__rdivmod__(self, value, /)
    Return divmod(value, self).

__repr__(self, /)
    Return repr(self).

__rfloordiv__(self, value, /)
    Return value//self.

__rmod__(self, value, /)
    Return value%self.

__rmul__(self, value, /)
    Return value*self.

__round__(self, ndigits=None, /)
    Return the Integral closest to x, rounding half toward even.

    When an argument is passed, work like built-in round(x, ndigits).

__rpow__(self, value, mod=None, /)
    Return pow(value, self, mod).

__rsub__(self, value, /)
    Return value-self.

__rtruediv__(self, value, /)
    Return value/self.

__sub__(self, value, /)
    Return self-value.

__truediv__(self, value, /)
    Return self/value.

__trunc__(self, /)
    Return the Integral closest to x between 0 and x.

as_integer_ratio(self, /)
    Return a pair of integers, whose ratio is exactly equal to the original float.

    The ratio is in lowest terms and has a positive denominator.  Raise
    OverflowError on infinities and a ValueError on NaNs.

    >>> (10.0).as_integer_ratio()
    (10, 1)
    >>> (0.0).as_integer_ratio()
    (0, 1)
    >>> (-.25).as_integer_ratio()
    (-1, 4)

conjugate(self, /)
    Return self, the complex conjugate of any float.

hex(self, /)
    Return a hexadecimal representation of a floating-point number.

    >>> (-0.1).hex()
    '-0x1.999999999999ap-4'
    >>> 3.14159.hex()
    '0x1.921f9f01b866ep+1'

is_integer(self, /)
    Return True if the float is an integer.

----------------------------------------------------------------------
Class methods defined here:

__getformat__(typestr, /) from type
    You probably don't want to use this function.

      typestr
        Must be 'double' or 'float'.

    It exists mainly to be used in Python's test suite.

    This function returns whichever of 'unknown', 'IEEE, big-endian' or 'IEEE,
    little-endian' best describes the format of floating point numbers used by the
    C type named by typestr.

fromhex(string, /) from type
    Create a floating-point number from a hexadecimal string.

    >>> float.fromhex('0x1.ffffp10')
    2047.984375
    >>> float.fromhex('-0x1p-1074')
    -5e-324

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

imag
    the imaginary part of a complex number

real
    the real part of a complex number

y = 3.14  
print(type(y))  # 输出: <class 'float'>

complex

复数类型,由实部和虚部组成。

class complex(object)

complex(real=0, imag=0)

Create a complex number from a real part and an optional imaginary part.

This is equivalent to (real + imag*1j) where imag defaults to 0.

Methods defined here:

__abs__(self, /)
    abs(self)

__add__(self, value, /)
    Return self+value.

__bool__(self, /)
    True if self else False

__complex__(self, /)
    Convert this value to exact type complex.

__eq__(self, value, /)
    Return self==value.

__format__(self, format_spec, /)
    Convert to a string according to format_spec.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getnewargs__(self, /)

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__le__(self, value, /)
    Return self<=value.

__lt__(self, value, /)
    Return self<value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__neg__(self, /)
    -self

__pos__(self, /)
    +self

__pow__(self, value, mod=None, /)
    Return pow(self, value, mod).

__radd__(self, value, /)
    Return value+self.

__repr__(self, /)
    Return repr(self).

__rmul__(self, value, /)
    Return value*self.

__rpow__(self, value, mod=None, /)
    Return pow(value, self, mod).

__rsub__(self, value, /)
    Return value-self.

__rtruediv__(self, value, /)
    Return value/self.

__sub__(self, value, /)
    Return self-value.

__truediv__(self, value, /)
    Return self/value.

conjugate(self, /)
    Return the complex conjugate of its argument. (3-4j).conjugate() == 3+4j.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

imag
    the imaginary part of a complex number

real
    the real part of a complex number

z = 1 + 2j  
print(type(z))  # 输出: <class 'complex'>

序列类 5

str

字符串类型,用于表示文本数据。

class str(object)

str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or
errors is specified, then the object must expose a data buffer
that will be decoded using the given encoding and error handler.
Otherwise, returns the result of object.__str__() (if defined)
or repr(object).
encoding defaults to sys.getdefaultencoding().
errors defaults to 'strict'.

Methods defined here:

__add__(self, value, /)
    Return self+value.

__contains__(self, key, /)
    Return bool(key in self).

__eq__(self, value, /)
    Return self==value.

__format__(self, format_spec, /)
    Return a formatted version of the string as described by format_spec.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getitem__(self, key, /)
    Return self[key].

__getnewargs__(...)

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__mod__(self, value, /)
    Return self%value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__repr__(self, /)
    Return repr(self).

__rmod__(self, value, /)
    Return value%self.

__rmul__(self, value, /)
    Return value*self.

__sizeof__(self, /)
    Return the size of the string in memory, in bytes.

__str__(self, /)
    Return str(self).

capitalize(self, /)
    Return a capitalized version of the string.

    More specifically, make the first character have upper case and the rest lower
    case.

casefold(self, /)
    Return a version of the string suitable for caseless comparisons.

center(self, width, fillchar=' ', /)
    Return a centered string of length width.

    Padding is done using the specified fill character (default is a space).

count(...)
    S.count(sub[, start[, end]]) -> int

    Return the number of non-overlapping occurrences of substring sub in
    string S[start:end].  Optional arguments start and end are
    interpreted as in slice notation.

encode(self, /, encoding='utf-8', errors='strict')
    Encode the string using the codec registered for encoding.

    encoding
      The encoding in which to encode the string.
    errors
      The error handling scheme to use for encoding errors.
      The default is 'strict' meaning that encoding errors raise a
      UnicodeEncodeError.  Other possible values are 'ignore', 'replace' and
      'xmlcharrefreplace' as well as any other name registered with
      codecs.register_error that can handle UnicodeEncodeErrors.

endswith(...)
    S.endswith(suffix[, start[, end]]) -> bool

    Return True if S ends with the specified suffix, False otherwise.
    With optional start, test S beginning at that position.
    With optional end, stop comparing S at that position.
    suffix can also be a tuple of strings to try.

expandtabs(self, /, tabsize=8)
    Return a copy where all tab characters are expanded using spaces.

    If tabsize is not given, a tab size of 8 characters is assumed.

find(...)
    S.find(sub[, start[, end]]) -> int

    Return the lowest index in S where substring sub is found,
    such that sub is contained within S[start:end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.

format(...)
    S.format(*args, **kwargs) -> str

    Return a formatted version of S, using substitutions from args and kwargs.
    The substitutions are identified by braces ('{' and '}').

format_map(...)
    S.format_map(mapping) -> str

    Return a formatted version of S, using substitutions from mapping.
    The substitutions are identified by braces ('{' and '}').

index(...)
    S.index(sub[, start[, end]]) -> int

    Return the lowest index in S where substring sub is found,
    such that sub is contained within S[start:end].  Optional
    arguments start and end are interpreted as in slice notation.

    Raises ValueError when the substring is not found.

isalnum(self, /)
    Return True if the string is an alpha-numeric string, False otherwise.

    A string is alpha-numeric if all characters in the string are alpha-numeric and
    there is at least one character in the string.

isalpha(self, /)
    Return True if the string is an alphabetic string, False otherwise.

    A string is alphabetic if all characters in the string are alphabetic and there
    is at least one character in the string.

isascii(self, /)
    Return True if all characters in the string are ASCII, False otherwise.

    ASCII characters have code points in the range U+0000-U+007F.
    Empty string is ASCII too.

isdecimal(self, /)
    Return True if the string is a decimal string, False otherwise.

    A string is a decimal string if all characters in the string are decimal and
    there is at least one character in the string.

isdigit(self, /)
    Return True if the string is a digit string, False otherwise.

    A string is a digit string if all characters in the string are digits and there
    is at least one character in the string.

isidentifier(self, /)
    Return True if the string is a valid Python identifier, False otherwise.

    Call keyword.iskeyword(s) to test whether string s is a reserved identifier,
    such as "def" or "class".

islower(self, /)
    Return True if the string is a lowercase string, False otherwise.

    A string is lowercase if all cased characters in the string are lowercase and
    there is at least one cased character in the string.

isnumeric(self, /)
    Return True if the string is a numeric string, False otherwise.

    A string is numeric if all characters in the string are numeric and there is at
    least one character in the string.

isprintable(self, /)
    Return True if the string is printable, False otherwise.

    A string is printable if all of its characters are considered printable in
    repr() or if it is empty.

isspace(self, /)
    Return True if the string is a whitespace string, False otherwise.

    A string is whitespace if all characters in the string are whitespace and there
    is at least one character in the string.

istitle(self, /)
    Return True if the string is a title-cased string, False otherwise.

    In a title-cased string, upper- and title-case characters may only
    follow uncased characters and lowercase characters only cased ones.

isupper(self, /)
    Return True if the string is an uppercase string, False otherwise.

    A string is uppercase if all cased characters in the string are uppercase and
    there is at least one cased character in the string.

join(self, iterable, /)
    Concatenate any number of strings.

    The string whose method is called is inserted in between each given string.
    The result is returned as a new string.

    Example: '.'.join(['ab', 'pq', 'rs']) -> 'ab.pq.rs'

ljust(self, width, fillchar=' ', /)
    Return a left-justified string of length width.

    Padding is done using the specified fill character (default is a space).

lower(self, /)
    Return a copy of the string converted to lowercase.

lstrip(self, chars=None, /)
    Return a copy of the string with leading whitespace removed.

    If chars is given and not None, remove characters in chars instead.

partition(self, sep, /)
    Partition the string into three parts using the given separator.

    This will search for the separator in the string.  If the separator is found,
    returns a 3-tuple containing the part before the separator, the separator
    itself, and the part after it.

    If the separator is not found, returns a 3-tuple containing the original string
    and two empty strings.

removeprefix(self, prefix, /)
    Return a str with the given prefix string removed if present.

    If the string starts with the prefix string, return string[len(prefix):].
    Otherwise, return a copy of the original string.

removesuffix(self, suffix, /)
    Return a str with the given suffix string removed if present.

    If the string ends with the suffix string and that suffix is not empty,
    return string[:-len(suffix)]. Otherwise, return a copy of the original
    string.

replace(self, old, new, count=-1, /)
    Return a copy with all occurrences of substring old replaced by new.

      count
        Maximum number of occurrences to replace.
        -1 (the default value) means replace all occurrences.

    If the optional argument count is given, only the first count occurrences are
    replaced.

rfind(...)
    S.rfind(sub[, start[, end]]) -> int

    Return the highest index in S where substring sub is found,
    such that sub is contained within S[start:end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.

rindex(...)
    S.rindex(sub[, start[, end]]) -> int

    Return the highest index in S where substring sub is found,
    such that sub is contained within S[start:end].  Optional
    arguments start and end are interpreted as in slice notation.

    Raises ValueError when the substring is not found.

rjust(self, width, fillchar=' ', /)
    Return a right-justified string of length width.

    Padding is done using the specified fill character (default is a space).

rpartition(self, sep, /)
    Partition the string into three parts using the given separator.

    This will search for the separator in the string, starting at the end. If
    the separator is found, returns a 3-tuple containing the part before the
    separator, the separator itself, and the part after it.

    If the separator is not found, returns a 3-tuple containing two empty strings
    and the original string.

rsplit(self, /, sep=None, maxsplit=-1)
    Return a list of the substrings in the string, using sep as the separator string.

      sep
        The separator used to split the string.

        When set to None (the default value), will split on any whitespace
        character (including \n \r \t \f and spaces) and will discard
        empty strings from the result.
      maxsplit
        Maximum number of splits (starting from the left).
        -1 (the default value) means no limit.

    Splitting starts at the end of the string and works to the front.

rstrip(self, chars=None, /)
    Return a copy of the string with trailing whitespace removed.

    If chars is given and not None, remove characters in chars instead.

split(self, /, sep=None, maxsplit=-1)
    Return a list of the substrings in the string, using sep as the separator string.

      sep
        The separator used to split the string.

        When set to None (the default value), will split on any whitespace
        character (including \n \r \t \f and spaces) and will discard
        empty strings from the result.
      maxsplit
        Maximum number of splits (starting from the left).
        -1 (the default value) means no limit.

    Note, str.split() is mainly useful for data that has been intentionally
    delimited.  With natural text that includes punctuation, consider using
    the regular expression module.

splitlines(self, /, keepends=False)
    Return a list of the lines in the string, breaking at line boundaries.

    Line breaks are not included in the resulting list unless keepends is given and
    true.

startswith(...)
    S.startswith(prefix[, start[, end]]) -> bool

    Return True if S starts with the specified prefix, False otherwise.
    With optional start, test S beginning at that position.
    With optional end, stop comparing S at that position.
    prefix can also be a tuple of strings to try.

strip(self, chars=None, /)
    Return a copy of the string with leading and trailing whitespace removed.

    If chars is given and not None, remove characters in chars instead.

swapcase(self, /)
    Convert uppercase characters to lowercase and lowercase characters to uppercase.

title(self, /)
    Return a version of the string where each word is titlecased.

    More specifically, words start with uppercased characters and all remaining
    cased characters have lower case.

translate(self, table, /)
    Replace each character in the string using the given translation table.

      table
        Translation table, which must be a mapping of Unicode ordinals to
        Unicode ordinals, strings, or None.

    The table must implement lookup/indexing via __getitem__, for instance a
    dictionary or list.  If this operation raises LookupError, the character is
    left untouched.  Characters mapped to None are deleted.

upper(self, /)
    Return a copy of the string converted to uppercase.

zfill(self, width, /)
    Pad a numeric string with zeros on the left, to fill a field of the given width.

    The string is never truncated.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

maketrans(...)
    Return a translation table usable for str.translate().

    If there is only one argument, it must be a dictionary mapping Unicode
    ordinals (integers) or characters to Unicode ordinals, strings or None.
    Character keys will be then converted to ordinals.
    If there are two arguments, they must be strings of equal length, and
    in the resulting dictionary, each character in x will be mapped to the
    character at the same position in y. If there is a third argument, it
    must be a string, whose characters will be mapped to None in the result.

s = "Hello, World!"  
print(type(s))  # 输出: <class 'str'>

tuple

元组类型,不可变的序列。

class tuple(object)

tuple(iterable=(), /)

Built-in immutable sequence.

If no argument is given, the constructor returns an empty tuple.
If iterable is specified the tuple is initialized from iterable's items.

If the argument is a tuple, the return value is the same object.

Built-in subclasses:
    asyncgen_hooks
    UnraisableHookArgs

Methods defined here:

__add__(self, value, /)
    Return self+value.

__contains__(self, key, /)
    Return bool(key in self).

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getitem__(self, key, /)
    Return self[key].

__getnewargs__(self, /)

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__repr__(self, /)
    Return repr(self).

__rmul__(self, value, /)
    Return value*self.

count(self, value, /)
    Return number of occurrences of value.

index(self, value, start=0, stop=9223372036854775807, /)
    Return first index of value.

    Raises ValueError if the value is not present.

----------------------------------------------------------------------
Class methods defined here:

__class_getitem__(...) from type
    See PEP 585

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

t = (1, 2, 3)  
print(type(t))  # 输出: <class 'tuple'>

list

列表类型,可变的序列。

class list(object)

list(iterable=(), /)

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list.
The argument must be an iterable if specified.

Methods defined here:

__add__(self, value, /)
    Return self+value.

__contains__(self, key, /)
    Return bool(key in self).

__delitem__(self, key, /)
    Delete self[key].

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getitem__(self, index, /)
    Return self[index].

__gt__(self, value, /)
    Return self>value.

__iadd__(self, value, /)
    Implement self+=value.

__imul__(self, value, /)
    Implement self*=value.

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__repr__(self, /)
    Return repr(self).

__reversed__(self, /)
    Return a reverse iterator over the list.

__rmul__(self, value, /)
    Return value*self.

__setitem__(self, key, value, /)
    Set self[key] to value.

__sizeof__(self, /)
    Return the size of the list in memory, in bytes.

append(self, object, /)
    Append object to the end of the list.

clear(self, /)
    Remove all items from list.

copy(self, /)
    Return a shallow copy of the list.

count(self, value, /)
    Return number of occurrences of value.

extend(self, iterable, /)
    Extend list by appending elements from the iterable.

index(self, value, start=0, stop=9223372036854775807, /)
    Return first index of value.

    Raises ValueError if the value is not present.

insert(self, index, object, /)
    Insert object before index.

pop(self, index=-1, /)
    Remove and return item at index (default last).

    Raises IndexError if list is empty or index is out of range.

remove(self, value, /)
    Remove first occurrence of value.

    Raises ValueError if the value is not present.

reverse(self, /)
    Reverse *IN PLACE*.

sort(self, /, *, key=None, reverse=False)
    Sort the list in ascending order and return None.

    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the
    order of two equal elements is maintained).

    If a key function is given, apply it once to each list item and sort them,
    ascending or descending, according to their function values.

    The reverse flag can be set to sort in descending order.

----------------------------------------------------------------------
Class methods defined here:

__class_getitem__(...) from type
    See PEP 585

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data and other attributes defined here:

__hash__ = None

l = [1, 2, 3]  
print(type(l))  # 输出: <class 'list'>

bytes

字节序列类型,用于表示二进制数据。

class bytes(object)

bytes(iterable_of_ints) -> bytes
bytes(string, encoding[, errors]) -> bytes
bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer
bytes(int) -> bytes object of size given by the parameter initialized with null bytes
bytes() -> empty bytes object

Construct an immutable array of bytes from:
  - an iterable yielding integers in range(256)
  - a text string encoded using the specified encoding
  - any object implementing the buffer API.
  - an integer

Methods defined here:

__add__(self, value, /)
    Return self+value.

__buffer__(self, flags, /)
    Return a buffer object that exposes the underlying memory of the object.

__bytes__(self, /)
    Convert this value to exact type bytes.

__contains__(self, key, /)
    Return bool(key in self).

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getitem__(self, key, /)
    Return self[key].

__getnewargs__(...)

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__mod__(self, value, /)
    Return self%value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__repr__(self, /)
    Return repr(self).

__rmod__(self, value, /)
    Return value%self.

__rmul__(self, value, /)
    Return value*self.

__str__(self, /)
    Return str(self).

capitalize(...)
    B.capitalize() -> copy of B

    Return a copy of B with only its first character capitalized (ASCII)
    and the rest lower-cased.

center(self, width, fillchar=b' ', /)
    Return a centered string of length width.

    Padding is done using the specified fill character.

count(...)
    B.count(sub[, start[, end]]) -> int

    Return the number of non-overlapping occurrences of subsection sub in
    bytes B[start:end].  Optional arguments start and end are interpreted
    as in slice notation.

decode(self, /, encoding='utf-8', errors='strict')
    Decode the bytes using the codec registered for encoding.

    encoding
      The encoding with which to decode the bytes.
    errors
      The error handling scheme to use for the handling of decoding errors.
      The default is 'strict' meaning that decoding errors raise a
      UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
      as well as any other name registered with codecs.register_error that
      can handle UnicodeDecodeErrors.

endswith(...)
    B.endswith(suffix[, start[, end]]) -> bool

    Return True if B ends with the specified suffix, False otherwise.
    With optional start, test B beginning at that position.
    With optional end, stop comparing B at that position.
    suffix can also be a tuple of bytes to try.

expandtabs(self, /, tabsize=8)
    Return a copy where all tab characters are expanded using spaces.

    If tabsize is not given, a tab size of 8 characters is assumed.

find(...)
    B.find(sub[, start[, end]]) -> int

    Return the lowest index in B where subsection sub is found,
    such that sub is contained within B[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.

hex(...)
    Create a string of hexadecimal numbers from a bytes object.

      sep
        An optional single character or byte to separate hex bytes.
      bytes_per_sep
        How many bytes between separators.  Positive values count from the
        right, negative values count from the left.

    Example:
    >>> value = b'\xb9\x01\xef'
    >>> value.hex()
    'b901ef'
    >>> value.hex(':')
    'b9:01:ef'
    >>> value.hex(':', 2)
    'b9:01ef'
    >>> value.hex(':', -2)
    'b901:ef'

index(...)
    B.index(sub[, start[, end]]) -> int

    Return the lowest index in B where subsection sub is found,
    such that sub is contained within B[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Raises ValueError when the subsection is not found.

isalnum(...)
    B.isalnum() -> bool

    Return True if all characters in B are alphanumeric
    and there is at least one character in B, False otherwise.

isalpha(...)
    B.isalpha() -> bool

    Return True if all characters in B are alphabetic
    and there is at least one character in B, False otherwise.

isascii(...)
    B.isascii() -> bool

    Return True if B is empty or all characters in B are ASCII,
    False otherwise.

isdigit(...)
    B.isdigit() -> bool

    Return True if all characters in B are digits
    and there is at least one character in B, False otherwise.

islower(...)
    B.islower() -> bool

    Return True if all cased characters in B are lowercase and there is
    at least one cased character in B, False otherwise.

isspace(...)
    B.isspace() -> bool

    Return True if all characters in B are whitespace
    and there is at least one character in B, False otherwise.

istitle(...)
    B.istitle() -> bool

    Return True if B is a titlecased string and there is at least one
    character in B, i.e. uppercase characters may only follow uncased
    characters and lowercase characters only cased ones. Return False
    otherwise.

isupper(...)
    B.isupper() -> bool

    Return True if all cased characters in B are uppercase and there is
    at least one cased character in B, False otherwise.

join(self, iterable_of_bytes, /)
    Concatenate any number of bytes objects.

    The bytes whose method is called is inserted in between each pair.

    The result is returned as a new bytes object.

    Example: b'.'.join([b'ab', b'pq', b'rs']) -> b'ab.pq.rs'.

ljust(self, width, fillchar=b' ', /)
    Return a left-justified string of length width.

    Padding is done using the specified fill character.

lower(...)
    B.lower() -> copy of B

    Return a copy of B with all ASCII characters converted to lowercase.

lstrip(self, bytes=None, /)
    Strip leading bytes contained in the argument.

    If the argument is omitted or None, strip leading  ASCII whitespace.

partition(self, sep, /)
    Partition the bytes into three parts using the given separator.

    This will search for the separator sep in the bytes. If the separator is found,
    returns a 3-tuple containing the part before the separator, the separator
    itself, and the part after it.

    If the separator is not found, returns a 3-tuple containing the original bytes
    object and two empty bytes objects.

removeprefix(self, prefix, /)
    Return a bytes object with the given prefix string removed if present.

    If the bytes starts with the prefix string, return bytes[len(prefix):].
    Otherwise, return a copy of the original bytes.

removesuffix(self, suffix, /)
    Return a bytes object with the given suffix string removed if present.

    If the bytes ends with the suffix string and that suffix is not empty,
    return bytes[:-len(prefix)].  Otherwise, return a copy of the original
    bytes.

replace(self, old, new, count=-1, /)
    Return a copy with all occurrences of substring old replaced by new.

      count
        Maximum number of occurrences to replace.
        -1 (the default value) means replace all occurrences.

    If the optional argument count is given, only the first count occurrences are
    replaced.

rfind(...)
    B.rfind(sub[, start[, end]]) -> int

    Return the highest index in B where subsection sub is found,
    such that sub is contained within B[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.

rindex(...)
    B.rindex(sub[, start[, end]]) -> int

    Return the highest index in B where subsection sub is found,
    such that sub is contained within B[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Raise ValueError when the subsection is not found.

rjust(self, width, fillchar=b' ', /)
    Return a right-justified string of length width.

    Padding is done using the specified fill character.

rpartition(self, sep, /)
    Partition the bytes into three parts using the given separator.

    This will search for the separator sep in the bytes, starting at the end. If
    the separator is found, returns a 3-tuple containing the part before the
    separator, the separator itself, and the part after it.

    If the separator is not found, returns a 3-tuple containing two empty bytes
    objects and the original bytes object.

rsplit(self, /, sep=None, maxsplit=-1)
    Return a list of the sections in the bytes, using sep as the delimiter.

      sep
        The delimiter according which to split the bytes.
        None (the default value) means split on ASCII whitespace characters
        (space, tab, return, newline, formfeed, vertical tab).
      maxsplit
        Maximum number of splits to do.
        -1 (the default value) means no limit.

    Splitting is done starting at the end of the bytes and working to the front.

rstrip(self, bytes=None, /)
    Strip trailing bytes contained in the argument.

    If the argument is omitted or None, strip trailing ASCII whitespace.

split(self, /, sep=None, maxsplit=-1)
    Return a list of the sections in the bytes, using sep as the delimiter.

    sep
      The delimiter according which to split the bytes.
      None (the default value) means split on ASCII whitespace characters
      (space, tab, return, newline, formfeed, vertical tab).
    maxsplit
      Maximum number of splits to do.
      -1 (the default value) means no limit.

splitlines(self, /, keepends=False)
    Return a list of the lines in the bytes, breaking at line boundaries.

    Line breaks are not included in the resulting list unless keepends is given and
    true.

startswith(...)
    B.startswith(prefix[, start[, end]]) -> bool

    Return True if B starts with the specified prefix, False otherwise.
    With optional start, test B beginning at that position.
    With optional end, stop comparing B at that position.
    prefix can also be a tuple of bytes to try.

strip(self, bytes=None, /)
    Strip leading and trailing bytes contained in the argument.

    If the argument is omitted or None, strip leading and trailing ASCII whitespace.

swapcase(...)
    B.swapcase() -> copy of B

    Return a copy of B with uppercase ASCII characters converted
    to lowercase ASCII and vice versa.

title(...)
    B.title() -> copy of B

    Return a titlecased version of B, i.e. ASCII words start with uppercase
    characters, all remaining cased characters have lowercase.

translate(self, table, /, delete=b'')
    Return a copy with each character mapped by the given translation table.

      table
        Translation table, which must be a bytes object of length 256.

    All characters occurring in the optional argument delete are removed.
    The remaining characters are mapped through the given translation table.

upper(...)
    B.upper() -> copy of B

    Return a copy of B with all ASCII characters converted to uppercase.

zfill(self, width, /)
    Pad a numeric string with zeros on the left, to fill a field of the given width.

    The original string is never truncated.

----------------------------------------------------------------------
Class methods defined here:

fromhex(string, /) from type
    Create a bytes object from a string of hexadecimal numbers.

    Spaces between two numbers are accepted.
    Example: bytes.fromhex('B9 01EF') -> b'\\xb9\\x01\\xef'.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

maketrans(frm, to, /)
    Return a translation table useable for the bytes or bytearray translate method.

    The returned table will be one where each byte in frm is mapped to the byte at
    the same position in to.

    The bytes objects frm and to must be of the same length.

b = bytes([65, 66, 67])  # 对应ASCII中的'A', 'B', 'C'  
print(type(b))  # 输出: <class 'bytes'>

bytearray

可变字节序列类型。

class bytearray(object)

bytearray(iterable_of_ints) -> bytearray
bytearray(string, encoding[, errors]) -> bytearray
bytearray(bytes_or_buffer) -> mutable copy of bytes_or_buffer
bytearray(int) -> bytes array of size given by the parameter initialized with null bytes
bytearray() -> empty bytes array

Construct a mutable bytearray object from:
  - an iterable yielding integers in range(256)
  - a text string encoded using the specified encoding
  - a bytes or a buffer object
  - any object implementing the buffer API.
  - an integer

Methods defined here:

__add__(self, value, /)
    Return self+value.

__alloc__(...)
    B.__alloc__() -> int

    Return the number of bytes actually allocated.

__buffer__(self, flags, /)
    Return a buffer object that exposes the underlying memory of the object.

__contains__(self, key, /)
    Return bool(key in self).

__delitem__(self, key, /)
    Delete self[key].

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getitem__(self, key, /)
    Return self[key].

__gt__(self, value, /)
    Return self>value.

__iadd__(self, value, /)
    Implement self+=value.

__imul__(self, value, /)
    Implement self*=value.

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__mod__(self, value, /)
    Return self%value.

__mul__(self, value, /)
    Return self*value.

__ne__(self, value, /)
    Return self!=value.

__reduce__(self, /)
    Return state information for pickling.

__reduce_ex__(self, proto=0, /)
    Return state information for pickling.

__release_buffer__(self, buffer, /)
    Release the buffer object that exposes the underlying memory of the object.

__repr__(self, /)
    Return repr(self).

__rmod__(self, value, /)
    Return value%self.

__rmul__(self, value, /)
    Return value*self.

__setitem__(self, key, value, /)
    Set self[key] to value.

__sizeof__(self, /)
    Returns the size of the bytearray object in memory, in bytes.

__str__(self, /)
    Return str(self).

append(self, item, /)
    Append a single item to the end of the bytearray.

    item
      The item to be appended.

capitalize(...)
    B.capitalize() -> copy of B

    Return a copy of B with only its first character capitalized (ASCII)
    and the rest lower-cased.

center(self, width, fillchar=b' ', /)
    Return a centered string of length width.

    Padding is done using the specified fill character.

clear(self, /)
    Remove all items from the bytearray.

copy(self, /)
    Return a copy of B.

count(...)
    B.count(sub[, start[, end]]) -> int

    Return the number of non-overlapping occurrences of subsection sub in
    bytes B[start:end].  Optional arguments start and end are interpreted
    as in slice notation.

decode(self, /, encoding='utf-8', errors='strict')
    Decode the bytearray using the codec registered for encoding.

    encoding
      The encoding with which to decode the bytearray.
    errors
      The error handling scheme to use for the handling of decoding errors.
      The default is 'strict' meaning that decoding errors raise a
      UnicodeDecodeError. Other possible values are 'ignore' and 'replace'
      as well as any other name registered with codecs.register_error that
      can handle UnicodeDecodeErrors.

endswith(...)
    B.endswith(suffix[, start[, end]]) -> bool

    Return True if B ends with the specified suffix, False otherwise.
    With optional start, test B beginning at that position.
    With optional end, stop comparing B at that position.
    suffix can also be a tuple of bytes to try.

expandtabs(self, /, tabsize=8)
    Return a copy where all tab characters are expanded using spaces.

    If tabsize is not given, a tab size of 8 characters is assumed.

extend(self, iterable_of_ints, /)
    Append all the items from the iterator or sequence to the end of the bytearray.

    iterable_of_ints
      The iterable of items to append.

find(...)
    B.find(sub[, start[, end]]) -> int

    Return the lowest index in B where subsection sub is found,
    such that sub is contained within B[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.

hex(...)
    Create a string of hexadecimal numbers from a bytearray object.

      sep
        An optional single character or byte to separate hex bytes.
      bytes_per_sep
        How many bytes between separators.  Positive values count from the
        right, negative values count from the left.

    Example:
    >>> value = bytearray([0xb9, 0x01, 0xef])
    >>> value.hex()
    'b901ef'
    >>> value.hex(':')
    'b9:01:ef'
    >>> value.hex(':', 2)
    'b9:01ef'
    >>> value.hex(':', -2)
    'b901:ef'

index(...)
    B.index(sub[, start[, end]]) -> int

    Return the lowest index in B where subsection sub is found,
    such that sub is contained within B[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Raises ValueError when the subsection is not found.

insert(self, index, item, /)
    Insert a single item into the bytearray before the given index.

    index
      The index where the value is to be inserted.
    item
      The item to be inserted.

isalnum(...)
    B.isalnum() -> bool

    Return True if all characters in B are alphanumeric
    and there is at least one character in B, False otherwise.

isalpha(...)
    B.isalpha() -> bool

    Return True if all characters in B are alphabetic
    and there is at least one character in B, False otherwise.

isascii(...)
    B.isascii() -> bool

    Return True if B is empty or all characters in B are ASCII,
    False otherwise.

isdigit(...)
    B.isdigit() -> bool

    Return True if all characters in B are digits
    and there is at least one character in B, False otherwise.

islower(...)
    B.islower() -> bool

    Return True if all cased characters in B are lowercase and there is
    at least one cased character in B, False otherwise.

isspace(...)
    B.isspace() -> bool

    Return True if all characters in B are whitespace
    and there is at least one character in B, False otherwise.

istitle(...)
    B.istitle() -> bool

    Return True if B is a titlecased string and there is at least one
    character in B, i.e. uppercase characters may only follow uncased
    characters and lowercase characters only cased ones. Return False
    otherwise.

isupper(...)
    B.isupper() -> bool

    Return True if all cased characters in B are uppercase and there is
    at least one cased character in B, False otherwise.

join(self, iterable_of_bytes, /)
    Concatenate any number of bytes/bytearray objects.

    The bytearray whose method is called is inserted in between each pair.

    The result is returned as a new bytearray object.

ljust(self, width, fillchar=b' ', /)
    Return a left-justified string of length width.

    Padding is done using the specified fill character.

lower(...)
    B.lower() -> copy of B

    Return a copy of B with all ASCII characters converted to lowercase.

lstrip(self, bytes=None, /)
    Strip leading bytes contained in the argument.

    If the argument is omitted or None, strip leading ASCII whitespace.

partition(self, sep, /)
    Partition the bytearray into three parts using the given separator.

    This will search for the separator sep in the bytearray. If the separator is
    found, returns a 3-tuple containing the part before the separator, the
    separator itself, and the part after it as new bytearray objects.

    If the separator is not found, returns a 3-tuple containing the copy of the
    original bytearray object and two empty bytearray objects.

pop(self, index=-1, /)
    Remove and return a single item from B.

      index
        The index from where to remove the item.
        -1 (the default value) means remove the last item.

    If no index argument is given, will pop the last item.

remove(self, value, /)
    Remove the first occurrence of a value in the bytearray.

    value
      The value to remove.

removeprefix(self, prefix, /)
    Return a bytearray with the given prefix string removed if present.

    If the bytearray starts with the prefix string, return
    bytearray[len(prefix):].  Otherwise, return a copy of the original
    bytearray.

removesuffix(self, suffix, /)
    Return a bytearray with the given suffix string removed if present.

    If the bytearray ends with the suffix string and that suffix is not
    empty, return bytearray[:-len(suffix)].  Otherwise, return a copy of
    the original bytearray.

replace(self, old, new, count=-1, /)
    Return a copy with all occurrences of substring old replaced by new.

      count
        Maximum number of occurrences to replace.
        -1 (the default value) means replace all occurrences.

    If the optional argument count is given, only the first count occurrences are
    replaced.

reverse(self, /)
    Reverse the order of the values in B in place.

rfind(...)
    B.rfind(sub[, start[, end]]) -> int

    Return the highest index in B where subsection sub is found,
    such that sub is contained within B[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Return -1 on failure.

rindex(...)
    B.rindex(sub[, start[, end]]) -> int

    Return the highest index in B where subsection sub is found,
    such that sub is contained within B[start,end].  Optional
    arguments start and end are interpreted as in slice notation.

    Raise ValueError when the subsection is not found.

rjust(self, width, fillchar=b' ', /)
    Return a right-justified string of length width.

    Padding is done using the specified fill character.

rpartition(self, sep, /)
    Partition the bytearray into three parts using the given separator.

    This will search for the separator sep in the bytearray, starting at the end.
    If the separator is found, returns a 3-tuple containing the part before the
    separator, the separator itself, and the part after it as new bytearray
    objects.

    If the separator is not found, returns a 3-tuple containing two empty bytearray
    objects and the copy of the original bytearray object.

rsplit(self, /, sep=None, maxsplit=-1)
    Return a list of the sections in the bytearray, using sep as the delimiter.

      sep
        The delimiter according which to split the bytearray.
        None (the default value) means split on ASCII whitespace characters
        (space, tab, return, newline, formfeed, vertical tab).
      maxsplit
        Maximum number of splits to do.
        -1 (the default value) means no limit.

    Splitting is done starting at the end of the bytearray and working to the front.

rstrip(self, bytes=None, /)
    Strip trailing bytes contained in the argument.

    If the argument is omitted or None, strip trailing ASCII whitespace.

split(self, /, sep=None, maxsplit=-1)
    Return a list of the sections in the bytearray, using sep as the delimiter.

    sep
      The delimiter according which to split the bytearray.
      None (the default value) means split on ASCII whitespace characters
      (space, tab, return, newline, formfeed, vertical tab).
    maxsplit
      Maximum number of splits to do.
      -1 (the default value) means no limit.

splitlines(self, /, keepends=False)
    Return a list of the lines in the bytearray, breaking at line boundaries.

    Line breaks are not included in the resulting list unless keepends is given and
    true.

startswith(...)
    B.startswith(prefix[, start[, end]]) -> bool

    Return True if B starts with the specified prefix, False otherwise.
    With optional start, test B beginning at that position.
    With optional end, stop comparing B at that position.
    prefix can also be a tuple of bytes to try.

strip(self, bytes=None, /)
    Strip leading and trailing bytes contained in the argument.

    If the argument is omitted or None, strip leading and trailing ASCII whitespace.

swapcase(...)
    B.swapcase() -> copy of B

    Return a copy of B with uppercase ASCII characters converted
    to lowercase ASCII and vice versa.

title(...)
    B.title() -> copy of B

    Return a titlecased version of B, i.e. ASCII words start with uppercase
    characters, all remaining cased characters have lowercase.

translate(self, table, /, delete=b'')
    Return a copy with each character mapped by the given translation table.

      table
        Translation table, which must be a bytes object of length 256.

    All characters occurring in the optional argument delete are removed.
    The remaining characters are mapped through the given translation table.

upper(...)
    B.upper() -> copy of B

    Return a copy of B with all ASCII characters converted to uppercase.

zfill(self, width, /)
    Pad a numeric string with zeros on the left, to fill a field of the given width.

    The original string is never truncated.

----------------------------------------------------------------------
Class methods defined here:

fromhex(string, /) from type
    Create a bytearray object from a string of hexadecimal numbers.

    Spaces between two numbers are accepted.
    Example: bytearray.fromhex('B9 01EF') -> bytearray(b'\\xb9\\x01\\xef')

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

maketrans(frm, to, /)
    Return a translation table useable for the bytes or bytearray translate method.

    The returned table will be one where each byte in frm is mapped to the byte at
    the same position in to.

    The bytes objects frm and to must be of the same length.

----------------------------------------------------------------------
Data and other attributes defined here:

__hash__ = None

ba = bytearray([65, 66, 67])  
print(type(ba))  # 输出: <class 'bytearray'>

字典和集合 3

dict

字典类型,存储键值对。

class dict(object)

dict() -> new empty dictionary
dict(mapping) -> new dictionary initialized from a mapping object's
    (key, value) pairs
dict(iterable) -> new dictionary initialized as if via:
    d = {}
    for k, v in iterable:
        d[k] = v
dict(**kwargs) -> new dictionary initialized with the name=value pairs
    in the keyword argument list.  For example:  dict(one=1, two=2)

Methods defined here:

__contains__(self, key, /)
    True if the dictionary has the specified key, else False.

__delitem__(self, key, /)
    Delete self[key].

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getitem__(self, key, /)
    Return self[key].

__gt__(self, value, /)
    Return self>value.

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__ior__(self, value, /)
    Return self|=value.

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__ne__(self, value, /)
    Return self!=value.

__or__(self, value, /)
    Return self|value.

__repr__(self, /)
    Return repr(self).

__reversed__(self, /)
    Return a reverse iterator over the dict keys.

__ror__(self, value, /)
    Return value|self.

__setitem__(self, key, value, /)
    Set self[key] to value.

__sizeof__(...)
    D.__sizeof__() -> size of D in memory, in bytes

clear(...)
    D.clear() -> None.  Remove all items from D.

copy(...)
    D.copy() -> a shallow copy of D

get(self, key, default=None, /)
    Return the value for key if key is in the dictionary, else default.

items(...)
    D.items() -> a set-like object providing a view on D's items

keys(...)
    D.keys() -> a set-like object providing a view on D's keys

pop(...)
    D.pop(k[,d]) -> v, remove specified key and return the corresponding value.

    If the key is not found, return the default if given; otherwise,
    raise a KeyError.

popitem(self, /)
    Remove and return a (key, value) pair as a 2-tuple.

    Pairs are returned in LIFO (last-in, first-out) order.
    Raises KeyError if the dict is empty.

setdefault(self, key, default=None, /)
    Insert key with a value of default if key is not in the dictionary.

    Return the value for key if key is in the dictionary, else default.

update(...)
    D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
    If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]
    If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v
    In either case, this is followed by: for k in F:  D[k] = F[k]

values(...)
    D.values() -> an object providing a view on D's values

----------------------------------------------------------------------
Class methods defined here:

__class_getitem__(...) from type
    See PEP 585

fromkeys(iterable, value=None, /) from type
    Create a new dictionary with keys from iterable and values set to value.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data and other attributes defined here:

__hash__ = None

d = {'a': 1, 'b': 2}  
print(type(d))  # 输出: <class 'dict'>

set

集合类型,包含不重复的元素。

class set(object)

set() -> new empty set object
set(iterable) -> new set object

Build an unordered collection of unique elements.

Methods defined here:

__and__(self, value, /)
    Return self&value.

__contains__(...)
    x.__contains__(y) <==> y in x.

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__gt__(self, value, /)
    Return self>value.

__iand__(self, value, /)
    Return self&=value.

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__ior__(self, value, /)
    Return self|=value.

__isub__(self, value, /)
    Return self-=value.

__iter__(self, /)
    Implement iter(self).

__ixor__(self, value, /)
    Return self^=value.

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__ne__(self, value, /)
    Return self!=value.

__or__(self, value, /)
    Return self|value.

__rand__(self, value, /)
    Return value&self.

__reduce__(...)
    Return state information for pickling.

__repr__(self, /)
    Return repr(self).

__ror__(self, value, /)
    Return value|self.

__rsub__(self, value, /)
    Return value-self.

__rxor__(self, value, /)
    Return value^self.

__sizeof__(...)
    S.__sizeof__() -> size of S in memory, in bytes

__sub__(self, value, /)
    Return self-value.

__xor__(self, value, /)
    Return self^value.

add(...)
    Add an element to a set.

    This has no effect if the element is already present.

clear(...)
    Remove all elements from this set.

copy(...)
    Return a shallow copy of a set.

difference(...)
    Return the difference of two or more sets as a new set.

    (i.e. all elements that are in this set but not the others.)

difference_update(...)
    Remove all elements of another set from this set.

discard(...)
    Remove an element from a set if it is a member.

    Unlike set.remove(), the discard() method does not raise
    an exception when an element is missing from the set.

intersection(...)
    Return the intersection of two sets as a new set.

    (i.e. all elements that are in both sets.)

intersection_update(...)
    Update a set with the intersection of itself and another.

isdisjoint(...)
    Return True if two sets have a null intersection.

issubset(...)
    Report whether another set contains this set.

issuperset(...)
    Report whether this set contains another set.

pop(...)
    Remove and return an arbitrary set element.
    Raises KeyError if the set is empty.

remove(...)
    Remove an element from a set; it must be a member.

    If the element is not a member, raise a KeyError.

symmetric_difference(...)
    Return the symmetric difference of two sets as a new set.

    (i.e. all elements that are in exactly one of the sets.)

symmetric_difference_update(...)
    Update a set with the symmetric difference of itself and another.

union(...)
    Return the union of sets as a new set.

    (i.e. all elements that are in either set.)

update(...)
    Update a set with the union of itself and others.

----------------------------------------------------------------------
Class methods defined here:

__class_getitem__(...) from type
    See PEP 585

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data and other attributes defined here:

__hash__ = None

s = {1, 2, 3}  
print(type(s))  # 输出: <class 'set'>

frozenset

不可变集合类型。

class frozenset(object)

frozenset() -> empty frozenset object
frozenset(iterable) -> frozenset object

Build an immutable unordered collection of unique elements.

Methods defined here:

__and__(self, value, /)
    Return self&value.

__contains__(...)
    x.__contains__(y) <==> y in x.

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__ne__(self, value, /)
    Return self!=value.

__or__(self, value, /)
    Return self|value.

__rand__(self, value, /)
    Return value&self.

__reduce__(...)
    Return state information for pickling.

__repr__(self, /)
    Return repr(self).

__ror__(self, value, /)
    Return value|self.

__rsub__(self, value, /)
    Return value-self.

__rxor__(self, value, /)
    Return value^self.

__sizeof__(...)
    S.__sizeof__() -> size of S in memory, in bytes

__sub__(self, value, /)
    Return self-value.

__xor__(self, value, /)
    Return self^value.

copy(...)
    Return a shallow copy of a set.

difference(...)
    Return the difference of two or more sets as a new set.

    (i.e. all elements that are in this set but not the others.)

intersection(...)
    Return the intersection of two sets as a new set.

    (i.e. all elements that are in both sets.)

isdisjoint(...)
    Return True if two sets have a null intersection.

issubset(...)
    Report whether another set contains this set.

issuperset(...)
    Report whether this set contains another set.

symmetric_difference(...)
    Return the symmetric difference of two sets as a new set.

    (i.e. all elements that are in exactly one of the sets.)

union(...)
    Return the union of sets as a new set.

    (i.e. all elements that are in either set.)

----------------------------------------------------------------------
Class methods defined here:

__class_getitem__(...) from type
    See PEP 585

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

fs = frozenset([1, 2, 3])  
print(type(fs))  # 输出: <class 'frozenset'>

其他可迭代类 5

range

表示一个不可变的整数序列。

class range(object)

range(stop) -> range object
range(start, stop[, step]) -> range object

Return an object that produces a sequence of integers from start (inclusive)
to stop (exclusive) by step.  range(i, j) produces i, i+1, i+2, ..., j-1.
start defaults to 0, and stop is omitted!  range(4) produces 0, 1, 2, 3.
These are exactly the valid indices for a list of 4 elements.
When step is given, it specifies the increment (or decrement).

Methods defined here:

__bool__(self, /)
    True if self else False

__contains__(self, key, /)
    Return bool(key in self).

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getitem__(self, key, /)
    Return self[key].

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__ne__(self, value, /)
    Return self!=value.

__reduce__(...)
    Helper for pickle.

__repr__(self, /)
    Return repr(self).

__reversed__(...)
    Return a reverse iterator.

count(...)
    rangeobject.count(value) -> integer -- return number of occurrences of value

index(...)
    rangeobject.index(value) -> integer -- return index of value.
    Raise ValueError if the value is not present.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

start

step

stop

r = range(5)  
print(type(r))  # 输出: <class 'range'>

enumerate

同时获取可迭代对象的元素和索引。

class enumerate(object)

enumerate(iterable, start=0)

Return an enumerate object.

  iterable
    an object supporting iteration

The enumerate object yields pairs containing a count (from start, which
defaults to zero) and a value yielded by the iterable argument.

enumerate is useful for obtaining an indexed list:
    (0, seq[0]), (1, seq[1]), (2, seq[2]), ...

Methods defined here:

__getattribute__(self, name, /)
    Return getattr(self, name).

__iter__(self, /)
    Implement iter(self).

__next__(self, /)
    Implement next(self).

__reduce__(...)
    Return state information for pickling.

----------------------------------------------------------------------
Class methods defined here:

__class_getitem__(...) from type
    See PEP 585

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

for i, v in enumerate(['a', 'b', 'c']):  
    print(i, v)

slice

表示序列的切片操作。

class slice(object)

slice(stop)
slice(start, stop[, step])

Create a slice object.  This is used for extended slicing (e.g. a[0:10:2]).

Methods defined here:

__eq__(self, value, /)
    Return self==value.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__le__(self, value, /)
    Return self<=value.

__lt__(self, value, /)
    Return self<value.

__ne__(self, value, /)
    Return self!=value.

__reduce__(...)
    Return state information for pickling.

__repr__(self, /)
    Return repr(self).

indices(...)
    S.indices(len) -> (start, stop, stride)

    Assuming a sequence of length len, calculate the start and stop
    indices, and the stride length of the extended slice described by
    S. Out of bounds indices are clipped in a manner consistent with the
    handling of normal slices.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

start

step

stop

s = slice(1, 3)  
print(type(s))  # 输出: <class 'slice'>

reversed

返回一个逆序迭代器。

class reversed(object)

reversed(sequence, /)

Return a reverse iterator over the values of the given sequence.

Methods defined here:

__getattribute__(self, name, /)
    Return getattr(self, name).

__iter__(self, /)
    Implement iter(self).

__length_hint__(...)
    Private method returning an estimate of len(list(it)).

__next__(self, /)
    Implement next(self).

__reduce__(...)
    Return state information for pickling.

__setstate__(...)
    Set state information for unpickling.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

reversed_l = reversed([1, 2, 3])  
print(list(reversed_l))  # 输出: [3, 2, 1]

zip

将多个可迭代对象中的元素打包成一个个元组,然后返回由这些元组组成的对象。

class zip(object)

zip(*iterables, strict=False) --> Yield tuples until an input is exhausted.

   >>> list(zip('abcdefg', range(3), range(4)))
   [('a', 0, 0), ('b', 1, 1), ('c', 2, 2)]

The zip object yields n-length tuples, where n is the number of iterables
passed as positional arguments to zip().  The i-th element in every tuple
comes from the i-th iterable argument to zip().  This continues until the
shortest argument is exhausted.

If strict is true and one of the arguments is exhausted before the others,
raise a ValueError.

Methods defined here:

__getattribute__(self, name, /)
    Return getattr(self, name).

__iter__(self, /)
    Implement iter(self).

__next__(self, /)
    Implement next(self).

__reduce__(...)
    Return state information for pickling.

__setstate__(...)
    Set state information for unpickling.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

zipped = zip([1, 2], ['a', 'b'])  
print(list(zipped))  # 输出: [(1, 'a'), (2, 'b')]

映射和筛选 2

map

将一个函数应用于可迭代对象的所有元素。

class map(object)

map(func, *iterables) --> map object

Make an iterator that computes the function using arguments from
each of the iterables.  Stops when the shortest iterable is exhausted.

Methods defined here:

__getattribute__(self, name, /)
    Return getattr(self, name).

__iter__(self, /)
    Implement iter(self).

__next__(self, /)
    Implement next(self).

__reduce__(...)
    Return state information for pickling.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

squared = map(lambda x: x**2, [1, 2, 3])  
print(list(squared))  # 输出: [1, 4, 9]

filter

使用指定函数过滤可迭代对象的元素。

class filter(object)

filter(function or None, iterable) --> filter object

Return an iterator yielding those items of iterable for which function(item)
is true. If function is None, return the items that are true.

Methods defined here:

__getattribute__(self, name, /)
    Return getattr(self, name).

__iter__(self, /)
    Implement iter(self).

__next__(self, /)
    Implement next(self).

__reduce__(...)
    Return state information for pickling.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

filtered = filter(lambda x: x % 2 == 0, [1, 2, 3, 4])  
print(list(filtered))  # 输出: [2, 4]

类型和视图 2

type

用于获取对象类型或创建新类型。  

class type(object)

type(object) -> the object's type
type(name, bases, dict, **kwds) -> a new type

Methods defined here:

__call__(self, /, *args, **kwargs)
    Call self as a function.

__delattr__(self, name, /)
    Implement delattr(self, name).

__dir__(self, /)
    Specialized __dir__ implementation for types.

__getattribute__(self, name, /)
    Return getattr(self, name).

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__instancecheck__(self, instance, /)
    Check if an object is an instance.

__or__(self, value, /)
    Return self|value.

__repr__(self, /)
    Return repr(self).

__ror__(self, value, /)
    Return value|self.

__setattr__(self, name, value, /)
    Implement setattr(self, name, value).

__sizeof__(self, /)
    Return memory consumption of the type object.

__subclasscheck__(self, subclass, /)
    Check if a class is a subclass.

__subclasses__(self, /)
    Return a list of immediate subclasses.

mro(self, /)
    Return a type's method resolution order.

----------------------------------------------------------------------
Class methods defined here:

__prepare__(...)
    __prepare__() -> dict
    used to create the namespace for the class statement

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs)
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

__abstractmethods__

__annotations__

__dict__

__text_signature__

__type_params__

----------------------------------------------------------------------
Data and other attributes defined here:

__base__ = <class 'object'>
    The base class of the class hierarchy.

    When called, it accepts no arguments and returns a new featureless
    instance that has no instance attributes and cannot be given any.


__bases__ = (<class 'object'>,)

__basicsize__ = 920

__dictoffset__ = 264

__flags__ = 2156420354

__itemsize__ = 40

__mro__ = (<class 'type'>, <class 'object'>)

__weakrefoffset__ = 368

print(type(10))  # 输出: <class 'int'>

memoryview

创建一个给定参数的“内存查看”对象。

class memoryview(object)

memoryview(object)

Create a new memoryview object which references the given object.

Methods defined here:

__buffer__(self, flags, /)
    Return a buffer object that exposes the underlying memory of the object.

__delitem__(self, key, /)
    Delete self[key].

__enter__(...)

__eq__(self, value, /)
    Return self==value.

__exit__(...)

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getitem__(self, key, /)
    Return self[key].

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__iter__(self, /)
    Implement iter(self).

__le__(self, value, /)
    Return self<=value.

__len__(self, /)
    Return len(self).

__lt__(self, value, /)
    Return self<value.

__ne__(self, value, /)
    Return self!=value.

__release_buffer__(self, buffer, /)
    Release the buffer object that exposes the underlying memory of the object.

__repr__(self, /)
    Return repr(self).

__setitem__(self, key, value, /)
    Set self[key] to value.

cast(...)
    Cast a memoryview to a new format or shape.

hex(...)
    Return the data in the buffer as a str of hexadecimal numbers.

      sep
        An optional single character or byte to separate hex bytes.
      bytes_per_sep
        How many bytes between separators.  Positive values count from the
        right, negative values count from the left.

    Example:
    >>> value = memoryview(b'\xb9\x01\xef')
    >>> value.hex()
    'b901ef'
    >>> value.hex(':')
    'b9:01:ef'
    >>> value.hex(':', 2)
    'b9:01ef'
    >>> value.hex(':', -2)
    'b901:ef'

release(self, /)
    Release the underlying buffer exposed by the memoryview object.

tobytes(self, /, order='C')
    Return the data in the buffer as a byte string.

    Order can be {'C', 'F', 'A'}. When order is 'C' or 'F', the data of the
    original array is converted to C or Fortran order. For contiguous views,
    'A' returns an exact copy of the physical memory. In particular, in-memory
    Fortran order is preserved. For non-contiguous views, the data is converted
    to C first. order=None is the same as order='C'.

tolist(self, /)
    Return the data in the buffer as a list of elements.

toreadonly(self, /)
    Return a readonly version of the memoryview.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

c_contiguous
    A bool indicating whether the memory is C contiguous.

contiguous
    A bool indicating whether the memory is contiguous.

f_contiguous
    A bool indicating whether the memory is Fortran contiguous.

format
    A string containing the format (in struct module style)
    for each element in the view.

itemsize
    The size in bytes of each element of the memoryview.

nbytes
    The amount of space in bytes that the array would use in
    a contiguous representation.

ndim
    An integer indicating how many dimensions of a multi-dimensional
    array the memory represents.

obj
    The underlying object of the memoryview.

readonly
    A bool indicating whether the memory is read only.

shape
    A tuple of ndim integers giving the shape of the memory
    as an N-dimensional array.

strides
    A tuple of ndim integers giving the size in bytes to access
    each element for each dimension of the array.

suboffsets
    A tuple of integers used internally for PIL-style arrays.

arr = bytearray(b'abcdef')  
m = memoryview(arr)  
print(type(m))  # 输出: <class 'memoryview'>

类相关类型 5

object

所有类的基类。

class object

The base class of the class hierarchy.

When called, it accepts no arguments and returns a new featureless
instance that has no instance attributes and cannot be given any.

Built-in subclasses:
    anext_awaitable
    async_generator
    async_generator_asend
    async_generator_athrow
    ... and 90 other subclasses

Methods defined here:

__delattr__(self, name, /)
    Implement delattr(self, name).

__dir__(self, /)
    Default dir() implementation.

__eq__(self, value, /)
    Return self==value.

__format__(self, format_spec, /)
    Default object formatter.

    Return str(self) if format_spec is empty. Raise TypeError otherwise.

__ge__(self, value, /)
    Return self>=value.

__getattribute__(self, name, /)
    Return getattr(self, name).

__getstate__(self, /)
    Helper for pickle.

__gt__(self, value, /)
    Return self>value.

__hash__(self, /)
    Return hash(self).

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__le__(self, value, /)
    Return self<=value.

__lt__(self, value, /)
    Return self<value.

__ne__(self, value, /)
    Return self!=value.

__reduce__(self, /)
    Helper for pickle.

__reduce_ex__(self, protocol, /)
    Helper for pickle.

__repr__(self, /)
    Return repr(self).

__setattr__(self, name, value, /)
    Implement setattr(self, name, value).

__sizeof__(self, /)
    Size of object in memory, in bytes.

__str__(self, /)
    Return str(self).

----------------------------------------------------------------------
Class methods defined here:

__init_subclass__(...) from type
    This method is called when a class is subclassed.

    The default implementation does nothing. It may be
    overridden to extend subclasses.

__subclasshook__(...) from type
    Abstract classes can override this to customize issubclass().

    This is invoked early on by abc.ABCMeta.__subclasscheck__().
    It should return True, False or NotImplemented.  If it returns
    NotImplemented, the normal algorithm is used.  Otherwise, it
    overrides the normal algorithm (and the outcome is cached).

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data and other attributes defined here:

__class__ = <class 'type'>
    type(object) -> the object's type
    type(name, bases, dict, **kwds) -> a new type

class MyClass(object):  
    pass

super

用于调用父类(超类)的一个方法。

class super(object)

super() -> same as super(__class__, <first argument>)
super(type) -> unbound super object
super(type, obj) -> bound super object; requires isinstance(obj, type)
super(type, type2) -> bound super object; requires issubclass(type2, type)
Typical use to call a cooperative superclass method:
class C(B):
    def meth(self, arg):
        super().meth(arg)
This works for class methods too:
class C(B):
    @classmethod
    def cmeth(cls, arg):
        super().cmeth(arg)

Methods defined here:

__get__(self, instance, owner=None, /)
    Return an attribute of instance, which is of type owner.

__getattribute__(self, name, /)
    Return getattr(self, name).

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__repr__(self, /)
    Return repr(self).

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

__self__
    the instance invoking super(); may be None

__self_class__
    the type of the instance invoking super(); may be None

__thisclass__
    the class invoking super()

class Parent:  
    def hello(self):  
        print("Hello from Parent")  
  
class Child(Parent):  
    def hello(self):  
        super().hello()  
        print("Hello from Child")  
  
c = Child()  
c.hello()  # 输出: Hello from Parent  
           #       Hello from Child

property

内置装饰器,用于将一个方法转换为类属性。

class property(object)

property(fget=None, fset=None, fdel=None, doc=None)

Property attribute.

  fget
    function to be used for getting an attribute value
  fset
    function to be used for setting an attribute value
  fdel
    function to be used for del'ing an attribute
  doc
    docstring

Typical use is to define a managed attribute x:

class C(object):
    def getx(self): return self._x
    def setx(self, value): self._x = value
    def delx(self): del self._x
    x = property(getx, setx, delx, "I'm the 'x' property.")

Decorators make defining new properties or modifying existing ones easy:

class C(object):
    @property
    def x(self):
        "I am the 'x' property."
        return self._x
    @x.setter
    def x(self, value):
        self._x = value
    @x.deleter
    def x(self):
        del self._x

Methods defined here:

__delete__(self, instance, /)
    Delete an attribute of instance.

__get__(self, instance, owner=None, /)
    Return an attribute of instance, which is of type owner.

__getattribute__(self, name, /)
    Return getattr(self, name).

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__set__(self, instance, value, /)
    Set an attribute of instance to value.

__set_name__(...)
    Method to set name of a property.

deleter(...)
    Descriptor to obtain a copy of the property with a different deleter.

getter(...)
    Descriptor to obtain a copy of the property with a different getter.

setter(...)
    Descriptor to obtain a copy of the property with a different setter.

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

__isabstractmethod__

fdel

fget

fset

​class Circle:  
    def __init__(self, radius):  
        self._radius = radius  
      
    @property  
    def radius(self):  
        return self._radius  
      
    @radius.setter  
    def radius(self, value):  
        self._radius = value  
  
c = Circle(5)  
print(c.radius)  # 输出: 5  
c.radius = 10  
print(c.radius)  # 输出: 10

classmethod

内置装饰器,它用于将一个方法转换为类方法。

class classmethod(object)

classmethod(function) -> method

Convert a function to be a class method.

A class method receives the class as implicit first argument,
just like an instance method receives the instance.
To declare a class method, use this idiom:

class C:
      @classmethod
      def f(cls, arg1, arg2, argN):
          ...

It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()).  The instance is ignored except for its class.
If a class method is called for a derived class, the derived class
object is passed as the implied first argument.

Class methods are different than C++ or Java static methods.
If you want those, see the staticmethod builtin.

Methods defined here:

__get__(self, instance, owner=None, /)
    Return an attribute of instance, which is of type owner.

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__repr__(self, /)
    Return repr(self).

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

__dict__

__func__

__isabstractmethod__

__wrapped__

​class MyClass:  
    @classmethod  
    def my_class_method(cls):  
        print("This is a class method")

MyClass.my_class_method()  # 输出: This is a class method 

staticmethod

内置装饰器,用于将普通函数转换为静态方法。

class staticmethod(object)

staticmethod(function) -> method

Convert a function to be a static method.

A static method does not receive an implicit first argument.
To declare a static method, use this idiom:

 class C:
         @staticmethod
         def f(arg1, arg2, argN):
             ...

It can be called either on the class (e.g. C.f()) or on an instance
(e.g. C().f()). Both the class and the instance are ignored, and
neither is passed implicitly as the first argument to the method.

Static methods in Python are similar to those found in Java or C++.
For a more advanced concept, see the classmethod builtin.

Methods defined here:

__call__(self, /, *args, **kwargs)
    Call self as a function.

__get__(self, instance, owner=None, /)
    Return an attribute of instance, which is of type owner.

__init__(self, /, *args, **kwargs)
    Initialize self.  See help(type(self)) for accurate signature.

__repr__(self, /)
    Return repr(self).

----------------------------------------------------------------------
Static methods defined here:

__new__(*args, **kwargs) from type
    Create and return a new object.  See help(type) for accurate signature.

----------------------------------------------------------------------
Data descriptors defined here:

__dict__

__func__

__isabstractmethod__

__wrapped__

class MyClass:  
    @staticmethod  
    def my_static_method():  
        print("This is a static method")  
  
MyClass.my_static_method()  # 输出: This is a static method

小结

内置类是Python编程语言的核心组成部分,它们使得开发者能够创建和操作各种数据结构和逻辑,可以编写出高效且易于维护的代码,从而构建出功能强大的应用程序。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/481246.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

[C++]日期类的实现

本专栏内容为&#xff1a;C学习专栏&#xff0c;分为初阶和进阶两部分。 通过本专栏的深入学习&#xff0c;你可以了解并掌握C。 &#x1f493;博主csdn个人主页&#xff1a;小小unicorn ⏩专栏分类&#xff1a;C &#x1f69a;代码仓库&#xff1a;小小unicorn的代码仓库&…

【TB作品】430单片机,单片机串口多功能通信,Proteus仿真

文章目录 题目功能仿真图程序介绍代码、仿真、原理图、PCB 题目 60、单片机串口多功能通信 基本要求: 设计一串口通信程序,波特率38400,通过RS232与PC机通信。 自动循环发送数据串(设计在程序中) 接收并存储和显示该数据串 在发送端定义10个ASCII码键0-9 按键发送单字节,PC机接…

网络上常见的环路指的是什么

人类的创造力与破坏力同样强大"。 网路互通&#xff0c;同样也衍生出纷繁复杂的路由协议和各种因特网服务&#xff0c;以及"网络安全"这个庞大的领域。 这也是为什么说当今所有的网络通讯流量中&#xff0c;80%的资源都被浪费&#xff0c;只有20%被用以有效数…

AXS4004 5V 300mA 低噪声电荷泵 DCDC转换器 爱协生 参数文

概述 AXS4004是一款低噪声、固定频率360KHz的电荷泵型DC DC转换器&#xff0c;在输入电压2.5V到5V的情况下&#xff0c;恒定输出5V电压&#xff0c;电压精度为&#xff1a;3%&#xff0c;输出电流最大达到300mA。AXS4004外部零件少&#xff0c;非常适合小型的电池供电应用。AX…

【索引失效】MySQL索引失效场景

1、对索引使用左或者左右模糊匹配 当我们使用左或者左右模糊匹配的时候&#xff0c;也就是 like %xx 或者 like %xx% 这两种方式都会造成索引失效。 比如下面的 like 语句&#xff0c;查询 name 后缀为「林」的用户&#xff0c;执行计划中的 typeALL 就代表了全表扫描&#xff…

【VTKExamples::Points】第六期 ExtractSurface

很高兴在雪易的CSDN遇见你 VTK技术爱好者 QQ:870202403 公众号:VTK忠粉 前言 本文分享VTK样例ExtractSurface,并解析接口vtkSignedDistance & vtkExtractSurface,希望对各位小伙伴有所帮助! 感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步! 你的…

leetcode 225.用队列实现栈 JAVA

题目 思路 1.一种是用双端队列&#xff08;Deque&#xff09;&#xff0c;直接就可以调用很多现成的方法&#xff0c;非常方便。 2.另一种是用普通的队列&#xff08;Queue&#xff09;,要实现栈的先入后出&#xff0c;可以将最后一个元素的前面所有元素出队&#xff0c;然后…

LLM漫谈(五)| 从q star视角解密OpenAI 2027年实现AGI计划

最近&#xff0c;网上疯传OpenAI2027年关于AGI的计划。在本文&#xff0c;我们将针对部分细节以第一人称进行分享。​ 摘要&#xff1a;OpenAI于2022年8月开始训练一个125万亿参数的多模态模型。第一个阶段是Arrakis&#xff0c;也叫Q*&#xff0c;该模型于2023年12月完成训练&…

如何做好软件架构

最近学习了Udemy的一个软件架构课程&#xff0c;在此做一个记录和分享。 总的来说&#xff0c;软件架构是基于实际业务需求&#xff0c;无法为实际业务服务&#xff0c;再花哨的软件架构都无法产生任何价值。 当需求到来&#xff0c;我们需要分以下几个大致步骤进行分析和拆解…

JAVA_Tomcat

Tomcat 使用教程 1.下载: http://tomcat.apache.org/ 2.安装: 解压压缩包(安装目录不要有中文) 3.卸载: 删除目录即可 4.启动: 运行./bin/startup.sh1.黑窗口一闪而过: 没有配置好JDK环境变量2.启动报错(查看日志文件): 端口占用 5.关闭: 1.强制关闭: 点击窗口关闭按钮2.正常…

PTA 抢红包 25分 (JAVA)

题目描述 没有人没抢过红包吧…… 这里给出N个人之间互相发红包、抢红包的记录&#xff0c;请你统计一下他们抢红包的收获。 输入格式&#xff1a; 输出格式&#xff1a; 按照收入金额从高到低的递减顺序输出每个人的编号和收入金额&#xff08;以元为单位&#xff0c;输出小…

【循环神经网络rnn】一篇文章讲透

目录 引言 二、RNN的基本原理 代码事例 三、RNN的优化方法 1 长短期记忆网络&#xff08;LSTM&#xff09; 2 门控循环单元&#xff08;GRU&#xff09; 四、更多优化方法 1 选择合适的RNN结构 2 使用并行化技术 3 优化超参数 4 使用梯度裁剪 5 使用混合精度训练 …

147 Linux 网络编程3 ,高并发服务器 --多路I/O转接服务器 - select

从前面的知识学习了如何通过socket &#xff0c;多进程&#xff0c;多线程创建一个高并发服务器&#xff0c;但是在实际工作中&#xff0c;我们并不会用到前面的方法 去弄一个高并发服务器&#xff0c;有更加好用的方法&#xff0c;就是多路I/O转接器 零 多路I/O转接服务器 多…

Leetcode739. 每日温度

Every day a Leetcode 题目来源&#xff1a;739. 每日温度 解法1&#xff1a;单调栈-从左到右 单调栈中记录还没算出「下一个更大元素」的那些数&#xff08;的下标&#xff09;。 代码&#xff1a; /** lc appleetcode.cn id739 langcpp** [739] 每日温度*/// lc codesta…

深入理解指针03

1. 字符指针变量 在指针的类型中我们知道有⼀种指针类型为字符指针char*; ⼀般使⽤: int main(){char ch w;char *pc &ch;*pc w;return 0;} 还有⼀种使⽤⽅式如下: int main() {const char* pstr "hello world";//这⾥是把⼀个字符串放到pstr指针变量⾥了…

【Linux实践室】Linux用户管理实战指南:新建与删除用户操作详解

&#x1f308;个人主页&#xff1a;聆风吟_ &#x1f525;系列专栏&#xff1a;Linux实践室、网络奇遇记 &#x1f516;少年有梦不应止于心动&#xff0c;更要付诸行动。 文章目录 一. ⛳️任务描述二. ⛳️相关知识2.1 &#x1f514;Linux创建用户命令2.1.1 知识点讲解2.1.2 案…

OceanMind海睿思入选中国信通院《2023高质量数字化转型技术解决方案集》

近日&#xff0c;由中国信息通信研究院“铸基计划”编制的《2023高质量数字化转型技术解决方案集&#xff08;第一版&#xff09;》正式发布。 中新赛克海睿思 凭借卓越的产品力以及广泛的行业实践&#xff0c;成功入选该方案集的数据分析行业技术解决方案。 为促进数字化转型…

探索uni-app项目的架构与开发实践:快速开发的项目模板参考

摘要&#xff1a;本文将深入探讨uni-app项目架构的模板设计&#xff0c;以及如何通过使用该模板实现快速开发。我们将重点介绍模板中的组件示例、SDK示例和模板页面&#xff0c;并阐述它们在提高开发效率和优化用户体验方面的作用。 一、引言 随着移动互联网的迅猛发展&#…

每日一题 --- 209. 长度最小的子数组[力扣][Go]

长度最小子数组 题目&#xff1a; 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 连续 子数组 [numsl, numsl1, ..., numsr-1, numsr] &#xff0c;并返回其长度**。**如果不存在符合条件的子数组&#xff0c…

Learn OpenGL 19 几何着色器

几何着色器 在顶点和片段着色器之间有一个可选的几何着色器(Geometry Shader)&#xff0c;几何着色器的输入是一个图元&#xff08;如点或三角形&#xff09;的一组顶点。几何着色器可以在顶点发送到下一着色器阶段之前对它们随意变换。然而&#xff0c;几何着色器最有趣的地方…