Gemini 可以直接生成各种类型的文件以及zip压缩包了

2026-04-29 08:171阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐
问题描述:

如题,
看代码是直接在后台沙盒执行 Python 代码生成的文件。

代码

import os
import zipfile
from weasyprint import HTML

Create a directory for the files

dir_name = “random_files”
os.makedirs(dir_name, exist_ok=True)

1. TXT File

txt_content = “这是一个随机生成的文本文件内容。\n包含一些基本的文字描述。”
txt_path = os.path.join(dir_name, “sample.txt”)
with open(txt_path, “w”, encoding=“utf-8”) as f:
f.write(txt_content)

2. Markdown File

md_content = “# 随机 Markdown 文件\n\n## 章节 1\n这是 Markdown 格式的演示内容。

阅读全文
标签:人工智能
问题描述:

如题,
看代码是直接在后台沙盒执行 Python 代码生成的文件。

代码

import os
import zipfile
from weasyprint import HTML

Create a directory for the files

dir_name = “random_files”
os.makedirs(dir_name, exist_ok=True)

1. TXT File

txt_content = “这是一个随机生成的文本文件内容。\n包含一些基本的文字描述。”
txt_path = os.path.join(dir_name, “sample.txt”)
with open(txt_path, “w”, encoding=“utf-8”) as f:
f.write(txt_content)

2. Markdown File

md_content = “# 随机 Markdown 文件\n\n## 章节 1\n这是 Markdown 格式的演示内容。

阅读全文
标签:人工智能