O
O
Oleg Petrov2018-10-11 09:02:58
Python
Oleg Petrov, 2018-10-11 09:02:58

How to reformat the output of elements in the body of an email in Python?

At the moment I get the output :
coin1 coin2 coin3 .....
volume1 volume2 volume3 ....
close1 close2 close3 ......
How do I output this format in the body of the email?
coin1 volume1 close1
coin2 volume2 close2
coin3 volume3 volume3
....

sendcoins = coinscoins
#Разбиваю листы на значения функцией join
    sendcoins_str = ' '.join(sendcoins)  
    volumecoins_todaytoaverage_str = ' '.join(volumecoins_todaytoaverage)
    close_str = ' '.join(close_p)

    # Настройки
    mail_sender = 'xx'
    mail_receiver = 'xxx
    username = 'xxx'
    password = 'xxx'
    server = smtplib.SMTP('smtp.mail.ru:587')

    # Формируем тело письма
    subject = u'Монеты или токены с большим объемом '  # + mail_sender
#Вывожу значения в теле письма
    body = 'Coins: ' + sendcoins_str + '\n' + 'Volume_ratio: ' + volumecoins_todaytoaverage_str + '\n' + 'close: ' + close_p_str 
    msg = MIMEText(body, 'plain', 'utf-8')
    msg['Subject'] = Header(subject, 'utf-8')

    # Отправляем письмо
    server.starttls()
    server.ehlo()
    server.login(username, password)
    server.sendmail(mail_sender, mail_receiver, msg.as_string())
    server.quit()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question