我有一个使用ElementTree的Python小段代码,但是它不能使用cElementTree。为什么会这样呢?
#!/usr/bin/python3
import sys
import xml.etree.cElementTree as ET
tree = ET.parse(sys.stdin)
这会引发异常:
cElementTree.ParseError: no element found: line 1, column 0
当像这样调用它时:
echo "<a><b>c</b></a>" | ./xmltest.py
编辑:我刚刚注意到这个代码段可以在Python 2.7.2中运行,但无法在Python 3.2.2或3.1.4中运行。有什么想法吗?
更新:看起来在Python 3.3中已经修复了该问题。