🧪 Add subprocess open test file
This commit is contained in:
@@ -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)
|
||||||
Reference in New Issue
Block a user