Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
pythonqtwebkit:nextSibing不';t返回null或None_Python_Qt_Pyqt_Qtwebkit - Fatal编程技术网

pythonqtwebkit:nextSibing不';t返回null或None

pythonqtwebkit:nextSibing不';t返回null或None,python,qt,pyqt,qtwebkit,Python,Qt,Pyqt,Qtwebkit,下面是我用来获取给定节点所有子节点列表的代码片段。但是nextSibling()从不返回null,因此while循环将永远执行。请帮忙 children = [ ] children.append(documentElement.firstChild()) curr_node = children[0] while curr_node.nextSibling(): print curr_node, len(children) children.append(curr_

下面是我用来获取给定节点所有子节点列表的代码片段。但是nextSibling()从不返回null,因此while循环将永远执行。请帮忙

 children = [ ]
 children.append(documentElement.firstChild())
 curr_node = children[0]
 while curr_node.nextSibling():
     print curr_node, len(children)
     children.append(curr_node.nextSibling())
     curr_node = curr_node.nextSibling()

据我所知,nextSibling将始终返回QWebElement,但是您可以使用isNull()检查该元素是否为null元素

你可以登记 http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebelement.html#nextSibling

while not curr_node.nextSibling().isNull():
     print curr_node, len(children)
     children.append(curr_node.nextSibling())
     curr_node = curr_node.nextSibling()