[英]Run Powershell commands from Python
I know related questions where already posted, but I cannot get a hang of them. 我知道已经发布的相关问题,但是我无法理解。
I have a Powershell-command and put it in Python in a string, say string aa
. 我有一个Powershell命令,并将其放在Python中的字符串中,例如string
aa
。
How can I run command aa
from Python. 如何从Python运行命令
aa
。 I know I should use subprocess
, but I am not sure in what way. 我知道我应该使用
subprocess
,但是我不确定用什么方式。
Think of aa
as cd ../data
to get from the current folder to another folder, but also more complicated commands are possible, such as: 可以将
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
Thanks in advance 提前致谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.