从以下文本文件中,如何将所需的字符集从每一行提取到 python 中的列表中?所需字符为“ONLY REQUIRED1.JPG”、“ONLY REQUIRED2.JPG”、“ONLY REQUIRED3.JPG”。所以结果应该是:
result = ['ONLY REQUIRED1.JPG', 'ONLY REQUIRED2.JPG', 'ONLY REQUIRED3.JPG']
x'<xxx "-//xxx//xxxx//xx">\n<ggg>\n <kkk>\n <title>asdf asdf/xx/aaa.xxx/bbb.bb.cc</asdf>\n </head>\n <body>\n<pre>\ndhh\n</pre>\n<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> alt="[DIR]"> <a href="/asdf/kkkk.xxx/">Parent Directory</a> \n<img src="/lllll/ttt.gif" alt="[IMG]"> \n <a href="ONLY_REQUIRED1.JPG">ertwe</a> \n href="ONLY_REQUIRED2.JPG">x'<xxx "-//xxx//xxxx//xx">\n<ggg>\n <kkk>\n <title>asdf asdf/xx/aaa.xxx/bbb.bb.cc</asdf>\n </head>\n <body>\n<pre>\ndhh\n</pre>\n<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> \n href="ONLY_REQUIRED3.JPG">ertwe</a>