Skip to main content
 首页 » 编程设计

python之P4Python : AttributeError: type object 'P4' has no attribute 'Map'

2024年08月13日38pengyingh

这是我使用的代码:

from P4 import P4, P4Exception     
mp = P4.Map() 

这是我得到的错误:

mp = P4.Map() AttributeError: type object 'P4' has no attribute 'Map'

为什么? 根据 P4Python 手册,此类方法应构造一个新的 Map 对象。

请您参考如下方法:

因为您从 P4.py 导入了 class P4。 Map 是 P4.py 中的另一个类。查看源代码:https://github.com/rptb1/p4python/blob/master/P4.py

你应该试试这个:

import P4 
mp = P4.Map()