| 123456789101112 |
- import tempfile
- import os
- # 创建临时目录
- temp_dir = tempfile.mkdtemp(prefix="A")
- # 在临时目录中创建文件
- file_path = os.path.join(temp_dir, "my_file.txt")
- with open(file_path, 'w') as file:
- file.write("This is a file in a temporary directory.")
- print(file_path)
|