从Python运行Powershell命令

2024-09-28 20:49:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道相关的问题已经贴在哪里了,但我不知道它们的窍门。在

我有一个Powershell命令,把它放在Python中的一个字符串中,比如stringaa。在

如何从Python运行命令aa。我知道我应该使用subprocess,但我不确定用什么方式。在

aa想象为cd ../data,可以从当前文件夹到另一个文件夹,但也可以使用更复杂的命令,例如:

docker run --rm -v $pwd\xml\:C:\xml -i LocationOfRegistry powershell /C 'cat C:\xml\*.xml | python .\core-wrap\run.py' > output.csv

提前谢谢


Tags: dockerrun字符串命令文件夹data方式cd