简体   繁体   中英

Passing python variables into powershell

Looking for help with passing python variables into powershell.

Using the subprocess.call method to open powershell and run a powershell script that echos the variables from python I receive a not recognized error . Any help would be greatly appreciated.

Example python code:

row = ['hello' , 'world']
first = row[0]
second = row[1]
subprocess.call(["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
". \"./testShell2\";", "&variables(first, second)"])

Example powershell:

ECHO $first
ECHO $second

Error recieved

The term 'first' is not recognized as the name of a cmdlet, function, script file, or operable program.

Ended up using python instead of powershell to complete project. Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM