简体   繁体   中英

Remove unicode characters from returned variable - Tautulli Newsletter

I want to include actors from films in my Tautulli newsletter for my Plex media collection. The newsletter template file is html and the language is mako so a mix of python, html and css.

This code returns the correct values

<p style="font-family: 'Open Sans', Helvetica, Arial, sans-serif;font-weight: 400;margin: 0;max-width: 325px;color: #ffffff;">

Actors: ${movie['actors']}

</p>

It appears like

Actors: [u'Amalia Williamson', u'Celina Martin', u'Joelle Farrow']

To be usable I'd need to remove the the unicode characters

 [u'

I have tried a couple of things and this was the most promising lead, however I couldn't get it to work.

Can anyone please amend the code so it will work please? Thank you!

movie['actors'] appears to be a list, so rendering it will the repr of the list and its contents. Joining the invidual strings into a lrager string should do what you want.

>>> print u', '.join([u'Amalia Williamson', u'Celina Martin', u'Joelle Farrow'])
Amalia Williamson, Celina Martin, Joelle Farrow

In your template:

Actors: ${u', '.join(movie['actors'])}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM