Home > other >  Lines of text extraction contains keywords
Lines of text extraction contains keywords

Time:11-02

Anyone who can help me do a small script, line of text extraction contains keywords, example: a.t x files containing "PT" "2 0 3" line of the two keywords extracted
A.t xt:
1.2 0 3 8 89
3.2.2 56
0, 4, 54. 0, 4, 5, 56
5. 56 pt
0, 4, 556
6.2 0, 4, 57.2 0 3 5, 562, 4, 5, 56
56 pt
8.2 0, 4, 59.2 0 3 5 56
56
10.2 0, 4, 5
The extracted file:
1.2 0 3 8 89
5. 56 pt
0, 4, 57.2 0 3 5, 562, 4, 5, 56
56 pt
8.2 0, 4, 59.2 0 3 5 56

CodePudding user response:

 
Def test_txt () :
File_data=https://bbs.csdn.net/topics/open (' a.t xt)
For the l in file_data. Readlines () :
If l.f ind (' 2 0 3) & gt;=0 or l.f ind (' PT) & gt;=0:
Print (l.s trip ())
Test_txt ()
  • Related