#!/usr/bin/env python3 import os import time # 创建目录 try: os.makedirs('/root/tts/test_dir', exist_ok=True) print('Directory created: /root/tts/test_dir') except Exception as e: print('Error creating directory:', e) # 创建文件 try: with open('/root/tts/test.txt', 'w') as f: f.write('Test content: 和而不同 天下大同\n') f.write('Timestamp: ' + str(time.time()) + '\n') print('File created: /root/tts/test.txt') except Exception as e: print('Error creating file:', e) # 读取文件 try: with open('/root/tts/test.txt', 'r') as f: content = f.read() print('File content:') print(content) except Exception as e: print('Error reading file:', e)