【问题标题】:getting parameters for jython module获取 jython 模块的参数
【发布时间】:2023-03-28 09:01:01
【问题描述】:

我正试图弄清楚如何获取流入我的 jython websphere 相关模块的参数。我显然不明白这一点,所以任何帮助表示赞赏。这是我正在尝试的完全不令人满意/不起作用的方法:

execfile('wsadminlib.py')
Opts = {}
for key in Opts.key() :
  print(' option passed in is: ' + key)

#for c in listServerClusters():
#    startCluster(c);
#    print(c + ' status: ' + str(isClusterStarted(c)) )

【问题讨论】:

  • wsadminlib.py的内容是什么?你到底想完成什么?由于您将Opts 定义为{},因此当您尝试迭代其键时它将为空(应该是Opts.keys() 而不是Opts.key())。

标签: websphere jython


【解决方案1】:

如果你需要读取另一个文件/模块中定义的属性,你可以import他们。例如:

properties.py

properties = {
    'prop1': 'test'
}

def get():
    return properties

script.py

import properties

properties = properties.get()

print(properties['prop1'])

【讨论】:

    猜你喜欢
    • 2017-03-14
    • 2021-04-23
    • 2011-04-21
    • 1970-01-01
    • 1970-01-01
    • 2012-03-30
    • 1970-01-01
    • 1970-01-01
    • 2022-12-13
    相关资源
    最近更新 更多