我正在尝试使用 python 编辑一个 html 文本文件。打印时,它会给出一个空文件。为什么会变空?我试图打印它,因为我不知道如何退回它。 这是代码:
import bleach
with open ('index1.txt','w') as f: #to open the file that contains html markups
bleach.clean(
'f',
tags=['p'],
attributes=['style'],
styles=['color'],
)
f=open('index1.txt')
content = f.read()
f.close()
print(content)