变量问题

greex greex 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
def __init__(self,parentNode,node):
self.__node=node
self.__allChildNodes=[]
tmpTextValue=''
print 000
for item in self.__node.childNodes:
if(item.nodeType==1):
tmpNodeInfo=nodeInfo(self.__node,item)
setattr(tmpNodeInfo,tmpNodeInfo.tagName(),tmpNodeInfo.allChildNodes())
for itemKey in item.attributes.keys():
setattr(tmpNodeInfo,itemKey,item.getAttribute(itemKey))
print 222,tmpTextValue
if(len(tmpTextValue) > 0):
setattr(tmpNodeInfo,'textValue',tmpTextValue)
self.__allChildNodes.append(tmpNodeInfo)
elif item.nodeType==3 and len(item.nodeValue.strip())>0:
tmpTextValue=item.nodeValue.strip()
print 333,tmpTextValue

这是部分打印信息:
0
333 MSXML 5.0 SDK
222
222
tmpTextValue是先赋值的,怎么后面访问是又为空呢?
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
greex
脚本语言 37,737 成员 34,208 内容