【发布时间】:2018-09-16 22:19:06
【问题描述】:
我有一个 VBA 脚本,可以在一个名为 Visum 的软件中运行。这个脚本计算一些东西并将一些结果返回给软件。
我想要做的是将此脚本“转换”为 Python,但我对这部分代码有疑问:
VBA(工作,使用 Visum 库):
Dim PathList_0 As IPrTPathLinkList
Set PathList_0 = Visum.Lists.CreatePrTPathLinkList
Set DSeg = Visum.Net.DemandSegments.ItemByKey(Segmento_Demanda)
PathList_0.SetObjects newDemandSegOrPathSet:=DSeg, PathTypeSelection:=routeFilter_filterFromZoneFilter, ListFormat:=listFormat_databaseWithoutHeadLine, zone:=All
PathList_0.AddColumn ("OrigZoneNo")
aPath_0 = PathList_0.SaveToArray()
Python(不起作用...根据软件手册,没有必要导入任何“Visum”模块,因为我是在软件中运行此脚本):
PathList_0 = Visum.ListsCreatePrTPathLinkList #ERROR
DSeg = Visum.NetDemandSegments.ItemByKey(Segmento_Demanda)
PathList_0.SetObjects("All", DSeg, "routeFilter_filterFromZoneFilter", False, "listFormat_databaseWithoutHeadLine")
PathList_0.AddColumn("OrigZoneNo")
aPath_0 = PathList_0.SaveToArray()
当我运行 VBA 脚本时,它可以工作。但是当我运行 Python 脚本时,它会返回一个 AttributeError:
我已经阅读了一些关于 AttributeError 的类似问题,但我找不到针对这种特定情况的有用信息。我也读过dynamic.py和pyscript.py,但是由于我不是一个有经验的程序员,所以我无法找出问题所在。
我的 Python 版本与 Visum 软件兼容(我已经检查过了)。
我问这个问题是因为我认为这可能与我在“转换”为 Python 时犯的一些错误有关。谁能帮我解决这个错误?
【问题讨论】:
标签: python vba com attributeerror