簡體   English   中英

Python和RSS提要 - 解析進紙器

[英]Python and RSS feeds - parse feeder

我在python中使用feed解析器,我是python中的初學者。

for post in d.entries:
    if test_word3 and test_word2 in post.title:
        print(post.title)

我想要做的是讓feed解析器在RSS提要中的標題內找到幾個單詞。

請注意, 並且不會在in運算符中分發。

if test_word3 in post.title and
   test_word2 in post.title:

應該解決你的問題。 你寫的是評價為

if test_word3 and (test_word2 in post.title):

......這變成......

if (test_word3 != "") and (test_word2 in post.title):

簡化一點......字符串的布爾值是否為非空。 整數的布爾值是否為非零。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM