gpt4 book ai didi

python - 'NoneType' 对象在 OpenLCA 中没有属性 'append'

转载 作者:行者123 更新时间:2023-12-04 04:03:04 25 4
gpt4 key购买 nike

我正在使用 python 调用软件 OpenLCA 中的函数并在 openLCA 之外处理结果。 openLCA 为进程间通信 (IPC) 提供基于 JSON-RPC 的协议(protocol)的实现。但是,当我尝试将 Test_Parameter 的值更改为 2000 时出现以下错误:“NoneType”对象没有属性“append”。

我正在按照此处提到的确切说明进行操作:https://github.com/GreenDelta/olca-ipc.py

这是我的代码

import olca
import uuid
client = olca.Client(8080)

setup = olca.CalculationSetup()

redef = olca.ParameterRedef()
redef.name = 'Test_Parameter'
redef.value = 2000
setup.parameter_redefs.append(redef)

setup.calculation_type = olca.CalculationType.SIMPLE_CALCULATION
setup.impact_method = client.find(olca.ImpactMethod, 'ReCiPe Midpoint (H)')
setup.product_system = client.find(olca.ProductSystem, 'Test_Process')
setup.amount = 1.0


result = client.calculate(setup)
client.excel_export(result, 'hellotest.xlsx')
client.dispose(result)

如有任何帮助,我们将不胜感激。

非常感谢

最佳答案

https://github.com/GreenDelta/olca-ipc.py/blob/21effee30c41a99eb18f6b348f87cff53c23ea8c/olca/schema.py#L206

client.parameter_redefs 似乎被初始化为None。我没有看到通过类初始化它的定义方法,所以也许您应该直接这样做?

setup = olca.CalculationSetup()
setup.parameter_redefs = []

关于python - 'NoneType' 对象在 OpenLCA 中没有属性 'append',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62783490/

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