如何在Windows中使用子进程

如何在Windows中使用子进程,第1张

如何在Windows中使用子进程

我认为您正在寻找的是os.listdir()

查看os模块以获取更多信息

一个例子:

>>> import os>>> l = os.listdir()>>> print (l)['DLLs', 'Doc', 'google-python-exercises', 'include', 'Lib', 'libs', 'LICENSE.txt', 'NEWS.txt', 'python.exe', 'pythonw.exe', 'README.txt', 'tcl', 'Tools', 'VS2010Cmd.lnk']>>>

您还可以将输出读入列表:

result = []process = subprocess.Popen('dir',     shell=True,     stdout=subprocess.PIPE,     stderr=subprocess.PIPE )for line in process.stdout:    result.append(line)errpre = process.returnprefor line in result:    print(line)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5648139.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存