У меня есть текст, и я печатаю каждую его строку.
я хочу остановить (в первый раз просто напечатайте «флаг!», А во второй раз остановить) текст каждый раз, когда читаемая строка является флагом
но это не останавливает
кодовая часть:
import sys
path = "/somepath/story_line"
flag = "010001"
def process(line):
sys.stdout.write(line)
sys.stdout.flush()
time.sleep(2.4)
line = fileIN.readline()
with open(path, "r") as content:
if line != flag:
for line in content:
process(line)
if line == path:
print ("flag")
текстовая часть
[START]
010001
welcome traveler,
This story begins in a dark era where Evil took over the weak... Many times ago a dark force came from beyond the sky and over*** the balance of this land.
You are the hope and new strengh of this world, please choose wisely
....
....
Let the story begin
[END]
010001
GAME OVER !!!
Я новичок в Python, и я попытался с подпроцессом или добавить каждую строку в список, разобрать список, но ничего не делать.
может кто-нибудь может облегчить это?