/
rnekrasov
/
Python
Обзор
Документация
Войти
/
rnekrasov
/
Python
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Python Program to Merge Mails.py
20 строк
651 B
sayampradhan
Rename Python Program to Merge Mails to Python Program to Merge Mails.py
12 окт 2022, 11:31
Не верифицирован
12 окт 2022, 11:31
a3f9b48
Код
Авторство
О чём код?
# Python program to mail merger # Names are in the file names.txt # Body of the mail is in body.txt # open names.txt for reading with open("names.txt", 'r', encoding='utf-8') as names_file: # open body.txt for reading with open("body.txt", 'r', encoding='utf-8') as body_file: # read entire content of the body body = body_file.read() # iterate over names for name in names_file: mail = "Hello " + name.strip() + "\n" + body # write the mails to individual files with open(name.strip()+".txt", 'w', encoding='utf-8') as mail_file: mail_file.write(mail)