我得到了一个包含 850 行关于某个主题的不同问题的文本文件。
全部用小写字母书写。
我的最终目标是拥有一个文本文件,其中所有内容都以大写字母书写,除了停用词和问题开头的单词。
现在,我只是不知道如何将找到的单词转换为小写
# List of Stopwords
import os
import codecs
# open working directory
stopwords = open("C:\\Python Project\\Headings Generator\\stopwords.txt", "r" ,encoding='utf8',errors="ignore")
stopwordsList = [(line.strip()).title() for line in stopwords]
questions = open("C:\\Python Project\\Headings Generator\\questionslist.txt", "r" ,encoding='utf8',errors="ignore")
questionsList = [(line.strip()).title().split() for line in questions]
for sentences in questionsList:
for words in sentences:
if words in stopwordsList:
#How to replace the found word with a lowercase version of it?
非常感谢!