Including a Variable In the HTML Tags When Sending An Email

Richard Damon Richard at Damon-Family.org
Sat Aug 8 20:32:06 EDT 2020


On 8/8/20 8:03 PM, sammy.jackson987 at gmail.com wrote:
> If i use place holders i.e. {0} and {1} where {0} is the name and {1} is the dataframe i get an error for the following line of code:-
> .format((Name,Body).to_html()) which states 'tuple' object has no attribute 'to_html'.

I would do it as

.format(Name, Body.to_html()) if your names really are just straight
letters.

If they might have some funny characters that need html handling, you
could do:

import html


.format(html.escape(Name), Body.to_html())


Note that different types need to be treated differently to get them
into clean html.


-- 
Richard Damon



More information about the Python-list mailing list