0

I have a txt file like that,

<REC> 
<ID>= xxxxxxx
<name>= xxxxxxx
<peroid>= xxxxxxx
<time>= xxxxxxx
<event>= xxxxxxx

<event_supplement>= xxxxxxx

<event_supplement>= xxxxxxx 

I want to return the result:True when find REC or ID or name or peroid or time And result:False when find event or event_supplement, I use the code like,

with open("test.txt") as f:
  a_file = f.read().splitlines()

b_file = []
event = ""
for idx, line in enumerate(a_file):
    if "<REC>=" or "<ID>=" or "<name>=" or "<time>=" or "<peroid>=" in line:
        print(idx,"----True")
        b_file.append(line)
    elif "event" in line: 
        print(idx, "False")
    else:
        break

However, it both shows True in the result, no False, why and how to change it?

4daJKong
  • 1,521
  • 5
  • 17
  • Change `"=" or "=" or "=" or " – Samwise Feb 18 '22 at 02:01

0 Answers0