【发布时间】:2020-10-24 17:15:18
【问题描述】:
我正在尝试从 Python3 中的命令行读取 XML 输入。到目前为止,我尝试了各种方法,以下是我读取 XML 的代码,
import sys
import xml.dom.minidom
try:
input = sys.stdin.buffer
except AttributeError:
input = sys.stdin
xmlString = input.read()
但是这种持续获取输入请有人可以告诉如何在获取 XML 文件后停止获取输入
我的 XML 文件是,
<response>
<article>
<title>A Novel Approach to Image Classification, in a Cloud Computing Environment stability.</title>
<publicationtitle>IEEE Transactions on Cloud Computing</publicationtitle>
<abstract>Classification of items within PDF documents has always been challenging. This stability document will discuss a simple classification algorithm for indexing images within a PDF.</abstract>
</article>
<body>
<sec>
<label>I.</label>
<p>Should Haven't That is a bunch of text pattern these classification and cyrptography. These paragraphs are nothing but nonsense. What is the statbility of your program to find neural nets. Throw in some numbers to see if you get the word count correct this is a classification this in my nd and rd words. What the heck throw in cryptography.</p>
<p>I bet diseases you can't find probability twice. Here it is a again probability. Just to fool you I added it three times probability. Does this make any pattern classification? pattern classification! pattern classification.</p>
<p>
<fig>
<label>FIGURE.</label>
<caption>This is a figure representing convolutional neural nets.</caption>
</fig>
</p>
</sec>
</body>
</response>
由于它有很多行,我无法使用 input() 以传统方式输入它
【问题讨论】:
-
你为什么要惹
sys.stdin?为什么不直接使用input()? -
input() 只占用一行,对吗?我有包含多行的 XML 文件,我需要使用标准输入一次输入
标签: python python-3.x xml