【发布时间】:2016-05-18 21:19:47
【问题描述】:
这是我的代码
from pox.lib.addresses import IPAddr
def ip_atoi(st):
"""
function to convert ip address to integer value
"""
st=st.split(".")
return int("%02x%02x%02x%02x"%(int(st[0]),int(st[1]),int(st[2]),int(st[3])),16)
-
当我在 pox 控制器中运行此脚本时,我收到错误提示
AttributeError: 'IPAddr' object has no attribute 'split'
【问题讨论】:
-
对我来说似乎很简单。
st是一个IPAddr对象,而IPAddr对象没有split方法,因此当您尝试在IPAddr上调用split时它会崩溃。 -
IPAddr 类中有一个方法
toStr()。您应该先调用st.toStr(),然后再拆分它。第 294 行github.com/noxrepo/pox/blob/carp/pox/lib/addresses.py
标签: python python-2.7 sdn pox