I'm getting constantly changing text from a website and putting that into an HTML file then having the program read that Html file and find the text and input it into a .txt file but when I input it into the file the spaces are replaced with ?, Some people on discord helped me write one that removes them and they are gone but now they have no spaces and are just one long word. I need help replacing the ?'s with spaces. This is the code I currently have. If anyone is wondering it is, it is supposed to read text from Nitro Type and I know it probably isn't very efficient I don't need it to be I just need to replace the question marks with spaces and .replace() doesn't work with it. Sorry if this is a simple fix I'm super new to coding. FYI this isn't the full code the rest of it works.
with open("word.html", "r") as html_file:
content = html_file.read()
soup = BeautifulSoup(content, 'lxml')
words = soup.find_all('span', class_='dash-letter')
stuff = ""
for span in words:
if span.text.isascii():
stuff += span.text
with open("Sentence.txt", "w") as wf:
wf.write(stuff)
question from:
https://stackoverflow.com/questions/65651530/need-to-replace-with-space 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…