文档介绍:word
word
2 / 10
word
Python入门教程 超详细1小时学会Python
为什么使用Python
    假设我们有这么一项任务:.       思路:用shell编程.(Linux通常是bash而Windows是批处理脚本).例如,在Windows上用ping ip "Reply from ... " 而不通的时候文本是"time out ... " ,所以,在结果中进展字符串查找,即可知道该机器是否连通.    实现:Java代码如下:
String  ping ";String ipprefix=".";int begin=101;int end=200;Process p=null;for(int i=begin;i<end;i++){     p= ().exec(cmd+i);     String line = null;     BufferedReader reader = new BufferedReader(new InputStreamReader(()));     while((line = ()) != null)     {         //Handling line , may logs it.      }    ();    ();}    这段代码运行得很好,问题是为了运行这段代码,:
编写一个类文件
编写一个main方法
将之编译成字节代码
由于字节代码不能直接运行,你需要再写个小小的bat或者bash脚本来运行.
    当然,用C/C++++++和Java实现的区别,但在一些更为复杂的场景,,.
word
word
2 / 10
word
    同样的工作用Python实现如下:import subprocesscmd=""begin=101end=200while begin<end:    p=(cmd,shell=True,stdout=,                   stdin=,                   stderr=)    ("ping ."+str(begin)+"\n")    ()    ()    print "execution result: %s"%