我在编码版本的xml文件中使用beautifulsoup时遇到了这个问题
我有这个档案
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd“>
<modelVersion>4.0.0</modelVersion>
<artifactId>project</artifactId>
<packaging>pom</packaging>.....</project>
还有python代码
for file in files:
print(dir + file)
infile = open( dir + file,"r")
contents = infile.read()
soup = BeautifulSoup(contents, features ="xml")
print(soup.prettify())
打印的结果是
<?xml version="1.0" encoding="utf-8"?>
项目标记被忽略。它只发生在编码在第一行的文件中
相关问题 更多 >
编程相关推荐