Python 使用特定类型的对象时出现 AttributeError
Python AttributeError when using a specific type of object
我有一个 VBA 脚本,我 运行 来自一个名为 Visum 的软件。该脚本计算了一些东西并 returns 了软件的一些结果。
我想要做的是 "convert" 这个脚本到 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 脚本时,它 returns 一个 AttributeError:
我读过一些关于 AttributeError 的类似问题,但我找不到对这种特定情况有用的信息。我也读过 dynamic.py 和 pyscript.py,但由于我不是一个有经验的程序员,所以我找不到问题。
我的 Python 版本与 Visum 软件兼容(我已经检查过了)。
我问这个问题是因为我认为这可能与我在 "converting" 到 Python 时犯的一些错误有关。谁能帮我解决这个错误?
这只是一个错字:
PathList_0 = Visum.ListsCreatePrTPathLinkList
应该是
PathList_0 = Visum.Lists.CreatePrTPathLinkList
注意列表后面的点
我有一个 VBA 脚本,我 运行 来自一个名为 Visum 的软件。该脚本计算了一些东西并 returns 了软件的一些结果。
我想要做的是 "convert" 这个脚本到 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 脚本时,它 returns 一个 AttributeError:
我读过一些关于 AttributeError 的类似问题,但我找不到对这种特定情况有用的信息。我也读过 dynamic.py 和 pyscript.py,但由于我不是一个有经验的程序员,所以我找不到问题。
我的 Python 版本与 Visum 软件兼容(我已经检查过了)。
我问这个问题是因为我认为这可能与我在 "converting" 到 Python 时犯的一些错误有关。谁能帮我解决这个错误?
这只是一个错字:
PathList_0 = Visum.ListsCreatePrTPathLinkList
应该是
PathList_0 = Visum.Lists.CreatePrTPathLinkList
注意列表后面的点