我正在编写一个程序来逐行从程序中的文件中查找关键字。下面复制的一段代码用于将不区分大小写的关键字(关键字在列表 L 中)添加到列表中,可见,以便仅生成唯一的关键字,并添加到我拥有的关键字的计数中。代码如下:
for words in line:
if (words.upper() or words.lower() in L) and (not in seen): # this means a keyword was found
seen.append(words) # add keyword to the seen list to only find unique keywords
count += 1 # add to count of keywords in this line
但是,当我尝试运行它时,我的 if 语句会出现语法错误,并突出显示“未见”中的“在”。我的 if 语句有什么问题?
谢谢。