嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
将源文件放置在一个含有图片的文件夹下,运行程序文件,生成一个MHTML文档,方便直接在电脑和手机上预览图片。
def create_mht_file(folder_path):
# 获取当前文件夹的名称
folder_name = os.path.basename(folder_path)
mht_file_name = f"{folder_name}.mht"
mht_file_path = os.path.join(folder_path, mht_file_name)
# 查找当前文件夹中的所有图片文件
images = [f for f in os.listdir(folder_path) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp'))]
if not images:
print("当前文件夹没有图片文件。")
return
mhtml_content = []
# 创建 MHT 文件内容
mht_content = f"Content-Type: multipart/related; type=\"text/html\"; boundary=\"boundary\"\n"
mht_content = f"X-MHT-Document: {folder_name}\n\n"
mht_content = f"--boundary\n"
mht_content = f"Content-Type: text/html; charset=\"UTF-8\"\n\n"