我说:老师你好,你是教音乐的么?

他说:是的。教音乐修养的

我说:老师,你们的音乐课太无聊了,怎么不多欣赏现代流行音乐呢,非得枯燥的古典乐器?

他说:你安心学吧!

==============================================================================================

她说:快递号?

我说:xxxx

她说:没有!

我说:咋会啊?明明给我发了短信的。

她说:明明发给你的,你去找明明要,别挡着,下一位!5,与以为同学对话

我说:同学,能和你聊聊么?

===============================================================================================

我说:你咋不吃饭呢?

她说:不饿

我说:哦

她说:你去吃吧

我说:哦

她说:快去

我说:哦!


f = open('D:\\桌面\\record.txt',encoding = 'utf-8')

me = []

he = []

she = []

count = 1


for each_line in f:

    if each_line[:6] != '======':

        (role, line_spoken) = each_line.split(':',1)

        if role == '我说':

            me.append(line_spoken)

        if role == '他说':

            he.append(line_spoken)

        if role == '她说':

            she.append(line_spoken)

    else:

        file_name_me = 'Me_' + str(count) + '.txt'

        file_name_he = 'He_' + str(count) + '.txt'

        file_name_she = 'She_' + str(count) + '.txt'


        me_file = open(file_name_me,'w')

        he_file = open(file_name_he,'w')

        she_file = open(file_name_she,'w')

        

        me_file.writelines(me)

        he_file.writelines(he)

        she_file.writelines(she)


        me_file.close()

        he_file.close()

        she_file.close()


        me = []

        he = []

        she = []

        count += 1


file_name_me = 'Me_' + str(count) + '.txt'

file_name_he = 'He_' + str(count) + '.txt'

file_name_she = 'She_' + str(count) + '.txt'


me_file = open(file_name_me,'w')

he_file = open(file_name_he,'w')

she_file = open(file_name_she,'w')

        

me_file.writelines(me)

he_file.writelines(he)

she_file.writelines(she)


me_file.close()

he_file.close()

she_file.close()


f.close()