Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
このウェブサイト用に Python で簡単なパーサーを作成しました。以下は私のコードの一部です。 私の質問は次のとおりです。
p[1]
p[2]
p[3]
text1 = xmldata.xpath('//p[@class="MsoNormal"][1]//text()') a='' for i in text1: a=a+i.encode('cp1251') print a
背景を知らなくても、私はそのようなことしか提案できません:
texts = list(); index = 0; while(True): index += 1; try: temp = xmldata.xpath('//p[@class="MsoNormal"][%i]//text()' % index); except: break; else: texts.append();
このコード ブロックの後に、同じ要素のリストが表示されます。text1
text1