您可以使用 Python 的 subprocess 模块来执行命令并捕获输出:

import subprocess

result = subprocess.check_output(['openssl', 'rand', '-base64', '745'])

print(result)

这将执行 openssl rand -base64 745 命令并将输出作为字节字符串捕获到 result 变量中。如果您需要将其转换为字符串,请使用 decode() 方法:

result_str = result.decode('utf-8')
Python 执行 openssl rand -base64 命令并获取输出

原文地址: https://www.cveoy.top/t/topic/nCAg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录