1
我遇到了python变量作用域的问题。python范围问题
def getIP(data,address):
header = Header.fromData(data,0);
arcount = header._arcount //at this point arcount is some non-zero number
代码(仍然方法getIP内)后,我想看看是否arcount是否为零:
...
elif firstRR._type==RR.TYPE_NS:
while(nscount!=0):
print "arcount: ",arcount //here it gives 0. why?
if(arcount!=0):
print "arcount isn't 0"
else:
print "can't reach header"
这版画“无法到达头”,当我假设数量不应为零。为什么它没有看到弧度?谢谢
你确定你没有在被排除的代码的其他地方修改'arcount'吗?请张贴代码 – inspectorG4dget
您正在修改'arcount',直接或通过修改'header'。 – LSerni