[英]python scope issue
I'm having problems with python variable scopes. 我在使用python变量范围时遇到问题。
def getIP(data,address):
header = Header.fromData(data,0);
arcount = header._arcount //at this point arcount is some non-zero number
later in the code (still inside the method getIP) I want to see if arcount is zero or not: 稍后在代码中(仍在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"
And this prints "can't reach header", when I was assuming arcount shouldn't be zero. 当我假设arcount不应该为零时,这将显示“无法到达标头”。 Why it doesn't see arcount?
为什么看不到arcount? Thanks
谢谢
因为Python是强类型的,所以u'0'
和'0'
都不等于0
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.