gpt4 book ai didi

ironpython - Spotfire IronPython 循环遍历属性

转载 作者:行者123 更新时间:2023-12-01 12:31:49 28 4
gpt4 key购买 nike

如何使用 Ironpython 返回 Spotfire 文件中文档属性的完整列表。

属性可以通过

设置
Document.Properties["myProperty"] = "myValue"

我想做这样的事情

for myProperty in Document.Properties:
print myProperty
#Some checks like if myProperty.Name = 'name1' then ...

找到了这个,但还不能让它工作(它返回的不仅仅是属性:http://www.cambridgesoft.com/support/EnterpriseSupport/KnowledgeBase/FAQ/details/Default.aspx?TechNote=2344

from Spotfire.Dxp.Data import *

for DocProp in Document.Data.Properties.GetProperties(DataPropertyClass.Document):
print DocProp.Name, DocProp.Value

最佳答案

DocumentProperty 对象的一个​​名为 isUserVisible 的属性可以在此处为您提供帮助。

从技术上讲,列表中出现的所有内容都是文档属性(例如,它们是“文档的属性”),并且可以通过编辑»文档属性 访问它们。要获得您期望的 DocumentProperties(如“在此文档中创建的变量”),您可以运行如下命令:

from Spotfire.Dxp.Data import DataPropertyClass

for d in Document.Data.Properties.GetProperties(DataPropertyClass.Document):
if d.IsUserVisible: print d.Name, d.Value

你只需要DataPropertyClass用于枚举;没有进口也可以达到同样的效果:

for d in Document.Data.Properties.GetProperties(0):
if d.IsUserVisible: print d.Name, d.Value

(请注意,您仍会获得默认情况下随每个文档创建的 MaxMissingTimePartsFiscalYearOffset 属性。)

关于ironpython - Spotfire IronPython 循环遍历属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32433502/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com