非任意对象的集合? [英] Collections of non-arbitrary objects ?
问题描述
Python似乎有一个方法来记录任意
对象的集合:列表,元组,字典。但是,如果我想要一个非任意对象的集合
怎么办?记录列表,或类似的东西?
Python seems to have a log of ways to do collections of arbitrary
objects: lists, tuples, dictionaries. But what if I want a collection
of non-arbitrary objects? A list of records, or something like that?
推荐答案
walterbyrd写道:
walterbyrd wrote:
Python似乎有一个方法来记录任意
对象的集合:列表,元组,字典。但是,如果我想要一个非任意对象的集合
怎么办?记录列表,或类似的东西?
Python seems to have a log of ways to do collections of arbitrary
objects: lists, tuples, dictionaries. But what if I want a collection
of non-arbitrary objects? A list of records, or something like that?
将记录编码为对象(类)并将这些对象的实例放在
a中列表或字典(取决于所需的访问权限)。或者,如果你不想做/ b $ b很多记录只是把记录的每个实例(通常是一个记录是
实现为元组至少那个怎么样SQL数据库返回行内的
列表或字典(再次取决于所需的访问权限)。
-Larry
Code the record as an object (class) and place instances of those objects inside
a list or dictionary (depending on access required). Or if you don''t want to do
much with the records just put each instance of a record (normally a record is
implemented as a tuple at least thats how SQL databases return rows) inside a
list or a dictionary (again depending on access required).
-Larry
6月21日晚上8:19,walterbyrd< walterb ... @ iname.comwrote:
On Jun 21, 8:19 pm, walterbyrd <walterb...@iname.comwrote:
Python似乎有一个如何收集任意的b / b
对象:列表,元组,词典。
Python seems to have a log of ways to do collections of arbitrary
objects: lists, tuples, dictionaries.
和套装。
And sets.
但如果我想要一个系列怎么办
非任意对象?
But what if I want a collection
of non-arbitrary objects?
然后只将所需的对象类型放入集合中。
Then only put the kind of objects you want in the collection.
记录列表,或类似的东西
A list of records, or something like that
''记录''可以实现为元组,dicts或使用自定义类。
''Records'' can be implemented as tuples, dicts or using a custom class.
walterbyrd< wa ******** @ iname.comwrites:
walterbyrd <wa********@iname.comwrites:
Python似乎有一个记录方法任意
对象的集合:列表,元组,字典。但是,如果我想要一个非任意对象的
集合怎么办?一个记录列表,或类似的东西
?
Python seems to have a log of ways to do collections of arbitrary
objects: lists, tuples, dictionaries. But what if I want a
collection of non-arbitrary objects? A list of records, or something
like that?
然后以非任意方式收集它们。
这是一个轻率的反应,但我不是''理解这个问题。什么
你要求你还没有?列表可以包含已经相同类型的
对象序列。你有什么期望
列表没有提供?
-
\Faith可以简单定义作为一种不合逻辑的信念,不可能发生的事情发生了。 - Henry L. Mencken |
_o__)|
Ben Finney
Then collect them in a non-arbitrary way.
That''s a flippant response, but I don''t understand the question. What
are you asking for that you don''t already have? A list can contain a
sequence of objects of the same type already. What are you expecting
that a list does not provide?
--
\ "Faith may be defined briefly as an illogical belief in the |
`\ occurrence of the improbable." -- Henry L. Mencken |
_o__) |
Ben Finney
这篇关于非任意对象的集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!