🧪 Add subprocess open test file

This commit is contained in:
2026-05-15 04:36:19 +08:00
parent 5363f9239a
commit f6e7f9c4de
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env python3
import subprocess
from pathlib import Path
if __name__ == "__main__":
with open("output.log", "w") as f:
process = subprocess.Popen(
["ls", "-l"],
# cwd="/tmp",
stdout=f,
stderr=f,
)
process.wait() # 等待进程结束
t = Path("output.log").read_text(encoding="utf-8")
print(t)