由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Linux版 - 请教一个Python问题, 怎么读出一个data structure中的全部members (内容)?
相关主题
谁能介绍一下C++可扩展的librariessoftware raid 6 assemble求助
Kernel2.6.30带来新文件系统——NILFS请教一个Python问题, 怎么读出一个data structure中的全部members (内容)?
有没有人是从8.04在线升级到10.04的?GS structured credit group面试
如何让bash不自动转换数字?Bloomberg 电面
Please help me with u-boot求yelp内推
用了nohup怎么查运行到什么程度了?问一道关于Vector的题
弱弱的问个内核遍历当前进程的子进程的一小段程序请教python
以下的script能成立吗?应该怎么实现?请推荐最好的C++/Java/Python开源代码
相关话题的讨论汇总
话题: structure话题: python话题: 内容话题: data话题: members
进入Linux版参与讨论
1 (共1页)
d**s
发帖数: 920
1
祝大家春节好 !
给大家拜年 !
请教一个Python问题, 怎么读出一个data structure中的全部members(内容) ?
我在用一个的python library, 其中有一个data structure, 我知道它包括很多内容,
我的问题是:
- 怎么知道它包括什么内容 ?
- 怎么把它的内容读出来 ?
我首先想到的是把它转化成一个list,
such as:
a = list(DS) # DS is the data structure
这个会报错说:
TypeError: object is not iterable
请大家帮忙。
======================================================
具体来说: 我想读的是下面一个data structure的内容, 也许你有更具体的建议:
S*A
发帖数: 7142
2
you can try dir(obj) to get a list of the member of the obj.
Depend on how the obj is implemented. dir(obj) might not get
all the member if the obj has its own access function.
d**s
发帖数: 920
3
Hi, Thanks,
Yes,members has its own access function.
Is there a simple way to convert such structure to a list ? (Or in C/C++
term, casting to a list ? )
Thanks,

【在 S*A 的大作中提到】
: you can try dir(obj) to get a list of the member of the obj.
: Depend on how the obj is implemented. dir(obj) might not get
: all the member if the obj has its own access function.

S*A
发帖数: 7142
4
If member has own access function/slots etc,
Unless the class provide an enumerate function for you,
there is no way to enumerate all the members.
In that case, just read the documents. You seems using
some web DOM stuff. The documents should cover what
member is there.

【在 d**s 的大作中提到】
: Hi, Thanks,
: Yes,members has its own access function.
: Is there a simple way to convert such structure to a list ? (Or in C/C++
: term, casting to a list ? )
: Thanks,

1 (共1页)
进入Linux版参与讨论
相关主题
请推荐最好的C++/Java/Python开源代码Please help me with u-boot
PYTHON学起来不难,怎么做LEETCODE上的题这么难啊。问怎么搜SORT,SEARCH的题做?用了nohup怎么查运行到什么程度了?
刚才蹲厕所的时候弱弱的问个内核遍历当前进程的子进程的一小段程序
this question is nice以下的script能成立吗?应该怎么实现?
谁能介绍一下C++可扩展的librariessoftware raid 6 assemble求助
Kernel2.6.30带来新文件系统——NILFS请教一个Python问题, 怎么读出一个data structure中的全部members (内容)?
有没有人是从8.04在线升级到10.04的?GS structured credit group面试
如何让bash不自动转换数字?Bloomberg 电面
相关话题的讨论汇总
话题: structure话题: python话题: 内容话题: data话题: members