从返回的变量中删除Unicode字符-Tautulli新闻

时间:2019-03-22 12:00:26

标签: python html unicode ascii mako

我想在Tautulli时事通讯中将电影中的演员包括进我的Plex媒体收藏中。新闻稿模板文件是html,语言是mako,因此是python,html和css的混合。

此代码返回正确的值

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

Actors: ${movie['actors']}

</p>

看起来像

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

要使用,我需要删除unicode字符

 [u'

我尝试了几件事,this是最有前途的线索,但是我无法使它起作用。

任何人都可以修改代码,以便它可以正常工作吗?谢谢!

1 个答案:

答案 0 :(得分:0)

schedule[1].table_schedule_restriction_collection[0].parameter01_min = 20 似乎是一个列表,因此呈现该列表将代表该列表及其内容。将单个字符串连接到更大的字符串应该可以完成您想要的操作。

from bs4 import BeautifulSoup
html_doc = '<description>&lt;img src="https://www.somepicture.jpeg" align="left" hspace="8" width="400" height="200" /&gt; DESCRIPTION TEXT I WANT TO PARSE </description>'
soup = BeautifulSoup(html_doc, 'html.parser')
inner_soup = BeautifulSoup(soup.description.text, 'html.parser')
print(inner_soup.img.next_sibling)

在您的模板中:

movie['actors']