I am wanting to read the contents of a text file and filter out the bad word from it. {UPDATED} So I updated my python file after what you told me but right now I am getting a no module error. When I run pip3 install profanity_filter it gives me a big error.
I researched and found Profanity but it is not working
from profanity_filter import ProfanityFilter
pf = ProfanityFilter()
with open(input("Enter the name Of Your File"), "r") as myFile:
j = myFile.read()
filtered = pf.censor(j)
print(filtered)
You need to create an instance of the class, and then call its
censor()
method.And the argument has to be a string, not a list of strings. Call
read()
instead ofreadlines()
to get the entire file as a single string.