python - Beautiful table alignment out when sending table with email -


my table printing fine in console when email alignment gets distorted bit, suggestion how send perfectly, printing in console?

from beautifultable import beautifultable email.mime.multipart import mimemultipart email.mime.text import mimetext email.mime.base import mimebase email import encoders import smtplib table = beautifultable() a= ["name", "age", "class"] b=["jacob", 1, "boy"]  table.column_headers =a table.append_row(b) print table  def mailfunction(table):       fromaddr = "sender@gmail.com"     toaddr = "receiver@gmail.com"     msg = mimemultipart()      msg['from'] = fromaddr     msg['to'] = toaddr      msg['subject'] = " table print"      body = str(table)      msg.attach(mimetext(body, 'plain'))     server = smtplib.smtp('smtp.gmail.com:587')     server.starttls()     server.login(fromaddr, "password")     text = msg.as_string()     server.sendmail(fromaddr, toaddr, text)     server.quit()   mailfunction(table) 

console output:

+-------+-----+-------+ | name  | age | class | +-------+-----+-------+ | jacob |  1  |  boy  | +-------+-----+-------+ 

email output:

enter image description here

but when copy email notepad alignments normal


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

Ansible warning on jinja2 braces on when -

html - How to custom Bootstrap grid height? -