Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        6年前关闭。
                                                                                            
                
        
我需要编写一个python脚本来自动化一些重复的Linux命令。 (使用mac的人给我的命令)主要是mkdir和htk语音识别工具包命令。我需要在cygwin上执行这些命令。我尝试搜索有关如何执行此操作的教程,但还没有找到合适的教程。我是python的新手。

最佳答案

当我使用python替换外壳时,导入部分通常如下所示:

from os import mkdir, chdir
from shutil import move, copy, rmtree, copytree
from subprocess import call


这使我能够移动和复制文件和目录,以及创建新目录和删除目录。如果要在外壳上而不是在python函数上调用程序,请使用call模块中的subprocess

# To run the program foo that takes an option and two arguments
# Equivalent to "foo -d bar baz" directly in the shell
call(['foo', '-d', 'bar', 'baz'])


您可以将call用于htk。

关于python - 需要编写python脚本以在cygwin中执行linux命令,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15695917/

10-13 05:50
查看更多