CHILD: I saw giraffe swimming in the pool to get that ball.
Hi everyone!
Teacher: What is your name. what did you see?
CHILD: My name is John.I am a boy. I go to school everyday.I have
two brothers and sisters
Teacher: I saw giraffe swimming in the pool to get that ball .
我如何才能获得仅由Child讲述的台词?
答案 0 :(得分:2)
with open("sample.txt", "r") as file:
for line in file.readlines():
if "CHILD:" in line:
speaker = 1
elif "Teacher:" in line:
speaker = 2
if speaker == 1:
print(line)
那行得通。接下来,尝试发布您的方法。