Python中的 "可分配资源 "和 "容器 "有什么区别?

问题描述 投票:0回答:1

我正在学习数据结构.我已经知道Python容器是。List、Tuple、Set和Dictionary。

在Python的一道问答题中,有一道题是不得不识别以下哪个类是重载给定列表方法的类。

但是我不明白Python中Allocable resource的概念。它是指堆栈、队列、二叉树吗?

所以,我使用了dir()来挖掘每个类的内部,并找出它们是否有问题中指出的方法。

    """A classs overloads the following methods. Which of the following best describes objects
of this class?

__len__
__contains__
__getitem__
__setitem__

A) Generator
B) Iterator
C) Numeric
D) Allocable resource
E) Container
"""
# A) Generator
"""Is not a class"""
# B) Iterator
"""
dir(iter) = 
['__call__', '__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', 
'__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__',
 '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', 
 '__reduce_ex__', '__repr__', '__self__', '__setattr__', 
'__sizeof__', '__str__', '__subclasshook__', '__text_signature__']"""
# C) Numeric
"""dir(25) = 
['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', 
'__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', 
'__format__', '__ge__', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__index__',
 '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__',
  '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__',
   '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', 
   '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', 
   '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__',
    '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'bit_length', 
    'conjugate', 'denominator', 'from_bytes', 'imag', 'numerator', 'real', 'to_bytes']"""
# D) Allocable resource
"""???"""
# E) Container
"""Python's general purpose built-in containers, dict , list , set , and tuple """
"""dir(list) = 
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__',
 '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', 
 '__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__init_subclass__', 
 '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', 
 '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__', '__setattr__'
 , '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear', 
 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']"""
python containers theory
1个回答
0
投票

正确答案是:Allocable资源在Python中是一个模糊的术语,Python容器是指对题中所述方法具有可用性的容器。

© www.soinside.com 2019 - 2024. All rights reserved.