You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Brightway2提取ecoinvent活动的正确Description内容?

如何通过Brightway2获取ecoinvent活动的正确描述字段?

你遇到的问题是:用Brightway2提取ecoinvent数据库中特定活动(示例:wood preservation facility construction, dipping/immersion tank | wood preservation facility, dipping/immersion tank)的描述时,comment属性返回的是OpenLCA地理板块的说明,而你需要的是「General Information」板块的长描述。

解决方法如下:

  • 你要的描述对应ecoinvent原始数据里的活动文档描述,在Brightway2中并非存在于comment属性(该属性存储地理相关说明),而是在活动对象的documentation字典下的description字段。

具体操作代码

  1. 加载数据库并定位目标活动:
import brightway2 as bw

# 切换到你的Brightway项目
bw.projects.set_current("你的项目名称")
# 加载对应的ecoinvent数据库(替换为你实际使用的数据库名称)
ecoinvent_db = bw.Database("ecoinvent 3.9 cutoff")

# 搜索并获取目标活动
target_activity = ecoinvent_db.search(
    "wood preservation facility construction, dipping/immersion tank | wood preservation facility, dipping/immersion tank"
)[0]
  1. 提取正确的描述内容:
# 从documentation字典中提取描述
correct_description = target_activity.get("documentation", {}).get("description")

# 若存在则打印结果
if correct_description:
    print(correct_description)

备选提取方式

如果上述方法未获取到内容,可尝试直接读取活动的data属性(部分ecoinvent版本导入后描述会存储在此处):

correct_description = target_activity.data.get("description")

内容的提问来源于stack exchange,提问作者Q_T

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 07:11:07