我有一个代码来转换(.doc)到超文本标记语言文件。代码是:
import mammoth
f=open("c: ......\\demo.docx","rb")
b=open("ABC.html","wb")
document=mammoth.convert_to_html(f)
b.write(document.value.encode('utf8')) 现在将创建ABC.html。相反,我需要将HTML文档转换为与docx文件同名。
发布于 2019-12-29 20:37:50
您可以决定将哪个文件名用于输出文件-您可以只使用相同的名称:
dir = 'c:\...'
filename = 'demo'
input_file = os.path.join(dir, filename + '.docx')
output_file = filename + '.html'
f = open(input_file, "rb")
b = open(output_file,"wb") https://stackoverflow.com/questions/59519410
复制相似问题