如何获取子流程的输出以按照以下代码的格式附加列表。我已经搜索了该站点,但是找不到明确的答案
import subprocess
stafflist = 'staff.text'
passfile =[] # Generated from passgen_64
newDate = str(input('Enter new expiry date "Format = yyyy-mm-dd" '))
train_accounts = []
newAccounts = []
userFile = []
with open(stafflist) as file_object:
lines = file_object.readlines()
for line in lines:
if line.startswith('train'):
train_accounts.append(line.rstrip().split(':'))
pgen=subprocess.call(['/usr/bin/passgen_64'])
passfile.append(pgen)
print (passfile)
输入:2020-11-11
YnJ1dHJhbGF0cmE =
amE5NXN0eWJydXJp
c3R5ZHJ1c3Rv
cHJ1Z3Jhdmk =
YnJ1Z3JpZHJl
输出:
[0, 0, 0, 0, 0]
这不是我想要的,我需要密码文件为: ['YnJ1dHJhbGF0cmE =','amE5NXN0eWJydXJp','c3R5ZHJ1c3Rv','cHJ1Z3Jhdmk =','YnJ1Z3JpZHJl']