Python如何克服TypeError:“bool”对象不是iterab

2024-09-22 16:25:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我的问题是在ifany()语句中需要有两个条件,这两个条件是检查列表中的一个单词是否出现在一行中,以及第二个列表中的另一个单词是否也出现在同一行中。如果有,就打印出来。我在以前的函数中使用过这个,如果我只是检查了一个,所以我不需要使用And运算符,我尝试过阅读其他运算符,但是其他运算符不允许我达到我的条件。在

cleanLex中的lword(cleanLex是在readfiles.py文件)在

这是显示函数的部分代码

在主.py公司名称:

from collections import Counter
from Categories.GainingAccess import GA
from Readfiles import *

# Speech Act Categories
CategoryGA = GA
# ----------------------

# Word hit counters
CategoryHits = []
LexiconHits = []
# ----------------------

# unsure if used at this point
cleansedLex = []
# ----------------------

# Lists to hold lines where words have been matched
matchedCatlines = []
matchedLexlines = []
TestLine = []


def languagemodel():
    for line in cleanChat.values():
        for lword in [cleanLex]:
            for cword in [CategoryGA]:
                for section in line:
                    if any(lword and cword in section for lword in
                           cleanLex and cword in CategoryGA):  # searches each section to find words matching words stored in cleanLex
                print("matched words %s and %s", "on line:    %s",
                      (lword, cword, section))


languagemodel()

回溯错误:

^{pr2}$

关于如何解决或解决此问题的任何建议。在


Tags: andinfromimport列表forlinesection