# -*- coding: utf-8 -*- import re from pprint import pprint from pyquery import PyQuery as pq def again_parse(content): html = pq(content, parser="html") a = [] # print("###:", html.children()) if html.children(): for i, line in enumerate(html.children().items()): if str(line).startswith("", "\n").replace("
", "\n")) else: if "
" in str(line) or "
" in str(line): line = str(line).replace("
", "###").replace("
", "###") line = pq(line) new_line = list(map(lambda x: str(x) + "\n", line.text().split("###"))) a.extend(new_line) else: if line.text().strip(): a.append(line.text() + "\n") elif len(line.children()) > 1: res2 = [] for spans in line.children().items(): if "", "\n").replace("
", "\n")) else: res2.append(spans.html().replace("
", "\n").replace("
", "\n")) else: if "
" in str(spans) or "
" in str(spans): spans = str(spans).replace("
", "###").replace("
", "###") spans = pq(spans) new_spans = list(map(lambda x: str(x), spans.text().split("###"))) res2.extend(new_spans) else: if spans.text().strip(): res2.append(spans.text()) a.append(("".join(res2)+"\n")) elif str(line).startswith("It was 1504,and Columbus was making another trip to the New World.Columbus and his men needed fresh water and food after three months at sea.They saw an island and went on shore.On the island there were unfriendly Indians who refused to give food to them.Columbus’ men were afraid of the Indians,but he had a clever plan.He used sign language to tell the Indians about his mysterious (神秘的) power to turn off the light in the sky.He knew about a lunar eclipse ( 月蚀) the next night because the information was in his almanac ( 天 文 历 书).Columbus told the Indians,“Tomorrow night I’ll turn off the light in the sky.” But they didn’t believe him.When the eclipse began the next night,the Indians became very frightened.They begged Columbus to turn   on   the   light   again,and   they   quickly   gave   him   all   the   food   and   water   he wanted.Immediately Columbus and his men hurried back to the ship and sailed away in the moonless night.

1.Why did Columbus and his men stop at the island?

  • A.Because they wanted to meet the Indians there

  • B.Because they hoped to get supplies of food and water

  • C.Because they had never been on the island before

  • D.Because they had planned to visit it

2.The Indians     Columbus and his men.

  • A.were glad to see

  • B.were kind to

  • C.welcomed

  • D.were not kind to

3.How did Columbus tell the Indians that he had mysterious power?

  • A.He used movements of hands and expressions in his face

  • B.He spoke in the language of the Indians

  • C.He drew a lot of signs

  • D.He wrote in the language of the Indians


4.The Indians gave Columbus food and water because they   .

  • A.believed Columbus was a man with mysterious power

  • B.were interested in Columbustrip

  • C.wanted to help Columbus

  • D.were clever

【答案】1.A2.B3.C4.D

【解析】大风歌

''' # cons = open(r"C:\Users\HJ\Desktop\TEST_FILES\888.txt", encoding="utf-8").read() # # pprint(cons) pprint(again_parse(cons)) # again_parse(cons)