如何使用一个脚本的打印文本输出作为另一个脚本的命令行参数?

2024-04-28 15:08:44 发布

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

我有一个python脚本,它混合打印股票、头条新闻、我今天的google日历日程和外面的天气。我正在尝试找出如何使用这个文本输出作为Matt Dyson的惊人Google translate,text-to-speech脚本的内联参数:http://mattdyson.org/blog/2014/07/text-to-speech-on-a-raspberry-pi-using-google-translate/

基本上,我希望我的第一个脚本在每次运行时都能说出来。你知道吗

我正在寻找一个单独的脚本,它保留了第一个“打印”脚本的完整性,因为它是模块化的,并且只为其他脚本运行一系列execfile命令。你知道吗

我希望这有道理!?你知道吗

干杯!你知道吗


Tags: totext文本脚本参数googlemattspeech
1条回答
网友
1楼 · 发布于 2024-04-28 15:08:44

您是否考虑过将参数传递给调用Matt脚本的子进程?你知道吗

像这样

import subprocess
...
textcommand = #command to call your script
myProcess = subprocess.Popen(textCommand.split(), stdout=subprocess.PIPE)
textOutput = myProcess.communicate()[0]
....
mattCommand = 'python matts_script.py ' + outputText
mattProcess = subprocess.Popen(mattCommand.split())

根据OP输入编辑。你知道吗

相关问题 更多 >