从python运行非python prog [英] running non-python progs from python
问题描述
你好,我对python编程和编程一般都很新,但是
i编写了一个创建MIDI文件(.mid)的python prog,我想要
能够用另一个以BASIC编写的编程来播放。
这是一个命令行编程,它将MIDI文件名作为参数和
播放文件。
学习Python一书讲到了使用os.system调用,但是我没有把b $ b拿到这个工作。
如何从python脚本运行这个其他程序并传递文件名
作为参数?
hello, i''m fairly new to python programming and programming in general, but
i have written a python prog that creates a MIDI file (.mid) and I want to
be able to play it from another prog which is written in BASIC.
It''s a command-line prog that takes the MIDI filename as a parameter and
plays the file.
The ''Learning Python'' book talks about using the os.system call, but I
haven''t been able to get this to work.
How can I run this other program from a python script and pass the filename
as a parameter?
推荐答案
嗨!
您也可以(样本):
import os
vret = os.popen(''c:\\pfiles\\lplayer.exe'')
print vret
@ +
-
Michel Claveau
Hi !
You can also do (sample) :
import os
vret = os.popen(''c:\\pfiles\\lplayer.exe'')
print vret
@+
--
Michel Claveau
" Spiffy"写道:
"Spiffy" wrote:
学习Python一书谈到了使用os.system调用,但是我没有能够让它工作。
它不起作用描述一个问题是一种非常糟糕的方式你做了什么,b $ b做了什么,发生了什么,以及你期望会发生什么?
也看到:< >http:// www.catb.org/~esr/faqs/smart-...ons.html#intro
如何从python脚本运行其他程序并传递文件名
作为参数?
The ''Learning Python'' book talks about using the os.system call, but I
haven''t been able to get this to work.
"it doesn''t work" is a really lousy way to describe a problem what did you
do, what happened, and what did you expect would happen instead?
also see:
http://www.catb.org/~esr/faqs/smart-...ons.html#intro
How can I run this other program from a python script and pass the filename
as a parameter?
导入os
filename =" myfile"
os.system(" program%s"%filename)
< / F>
import os
filename = "myfile"
os.system("program %s" % filename)
</F>
" Michel Claveau / Hamster" <否******** @ No.Spam.mclaveau.No.Spam.com>写在
消息新闻:br ********** @ news-reader2.wanadoo.fr ...
"Michel Claveau/Hamster" <No********@No.Spam.mclaveau.No.Spam.com> wrote in
message news:br**********@news-reader2.wanadoo.fr...
嗨!
<你也可以(样本):
导入os
vret = os.popen(''c:\\pfiles\\lplayer.exe'')
打印vret
@ +
-
Michel Claveau
您好Michel,感谢您抽出宝贵时间回复。不幸的是,当我试图运行你的示例代码(当然是改变文件的名称)时,
什么也没做。
如何从python脚本运行这个其他程序并将
文件名作为参数传递?
import os
filename =" myfile"
os.system(" program%s" %filename)
< / F>
Fredrik,您提供的示例几乎与
学习Python书。当我运行它时,dos命令行显示
消息''错误的命令或文件名'。 .exe文件和.mid文件都在
的python路径中,并且已经检查了拼写。
我预计会发生的是os.system调用启动.exe
并开始播放.mid文件。这不会发生。这就是我的意思
,当我说我无法让它工作时。
它不起作用是一个非常糟糕的方式来描述一个>问题你做了什么,发生了什么,你期望会发生什么呢?
也看到:
http://www.catb.org/~ esr / faqs / smartquestions.html #intro
原谅我是个新手,但如果你没有答案,为什么你呢?
必须给我态度吗?
Pardon me for being a newbie, but if you don''t have an answer, why do you
have to give me attitude?
这篇关于从python运行非python prog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!