后台发送图片,但是没有进度条

This commit is contained in:
2024-08-27 04:20:49 +08:00
parent b788ab0dba
commit 07b89fe3cc
4 changed files with 12991 additions and 8 deletions

View File

@@ -0,0 +1,23 @@
import os
def read_files_recursively(directory, output_filename="llama.txt"):
"""
递归读取指定目录下的所有文件,并将它们的内容按顺序写入一个新文件中。
每个文件的内容以文件名和相对路径作为注释开头。
"""
script_filename = os.path.basename(__file__) # 获取当前脚本的文件名
with open(output_filename, "w", encoding="utf-8") as outfile:
for root, dirs, files in os.walk(directory):
for filename in sorted(files):
if filename != script_filename:
filepath = os.path.join(root, filename)
relative_path = os.path.relpath(filepath, directory)
outfile.write(f"### {relative_path} ###\n")
with open(filepath, "r", encoding="utf-8") as infile:
outfile.write(infile.read())
outfile.write("\n\n")
if __name__ == "__main__":
read_files_recursively(".") # 从当前目录开始递归读取