我试着编写一个python脚本来调用终端做一些简单的文本到脚本的东西:
import subprocess
text = "hello+world" #or any other texts
outputFileName = text+".mp3"
source = "\"http://translate.google.com/translate_tts?ie=UTF-8&tl=en&q="+text+"\""
cmd = "wget -q -U Mozilla -O "+outputFileName+" "+source
cmd2 = ["wget", "-q", "-U", "Mozilla", "-O", outputFileName, source]
subprocess.call(cmd, shell=True)
subprocess.call(cmd2)
但是,我从上述两个电话中获得了OSError: [Errno 2] No such file or directory
。我已经阅读了文档和其他一些线程,我想我可能错误地解析了wget
的参数,但仍然无法解决。