1 / 10
文档名称:

Python入门教程 超详细1小时学会Python.doc

格式:doc   大小:38KB   页数:10页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

Python入门教程 超详细1小时学会Python.doc

上传人:511709291 2021/12/4 文件大小:38 KB

下载得到文件列表

Python入门教程 超详细1小时学会Python.doc

相关文档

文档介绍

文档介绍: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"%