【发布时间】:2016-12-13 13:31:01
【问题描述】:
我正在使用来自 scipy.io.loadmat nested structures (i.e. dictionaries) 的代码将 matlab 结构读入 Python。我想列出出现在 dtype 列表中的字段名称列表。我的代码是:
matfile =loadmat(dataDirStr + matFileName, struct_as_record=True) # a dictionary
theseKeys = matfile.keys() #as list
thisDict = matfile[ theseKeys[ 1 ] ] #type = void1152, size = (1, 118)
#
#screen display of contents is:
#
dtype = [ ( 'Aircraft_Name', 'O'), ('Low_Mass', 'O') ]
因此,考虑到这一点,我想在 dtype 中创建条目列表:
thisList = [ 'Aircraft_Name', 'Low_Mass' ] #etc., etc.
这样可以保留 dtype 条目中名称的顺序。
你能帮帮我吗?
【问题讨论】: