带参数的Python子进程

2024-04-19 20:54:54 发布

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

我使用python子进程运行python脚本test.py。我想发送两个字符串'John', 'Henry'作为参数,并从测试.py. 我想要这样的东西

subprocess.call(['python3', 'test.py']) #add two names 'John', 'Henry' as argument

测试.py

print(name1) #print John
print(name2) #print Henry

我该怎么做?你知道吗


Tags: 字符串pytest脚本add参数names进程