Differences between revisions 1 and 12 (spanning 11 versions)
Revision 1 as of 2006-06-08 18:37:21
Size: 589
Editor: xiaobolee
Comment:
Revision 12 as of 2006-06-09 05:00:25
Size: 2034
Editor: xiaobolee
Comment:
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
== xiaobolee == = 一些零散笔记 =
Line 7: Line 7:
 CategoryHomepage == Python System Modules: ==
{{{
 . Sys与Os是python系统工具的核心,很多标准模块是从他们,原则上,sys导出与Python解释器相关的部件(例如模块的搜索路径),而os则包含了Python所运行的平台上的函数以及变量的映射。但这种界限比较模糊,例如标准的输入输出流是在Sys中的,它们明显是要和平台紧密联系的。
}}}
== os Modules ==
{{{
os.curdir…….os.getcwd()//得到当前目录
 1、os.path模块
 提供了大量的关于目录的工具。例如:os.path.isdir()……isfile()……exists()…..getsize()….
……split()…..join()….basename()….dirname()……splittext()…..
 2、在脚本文件中执行shell命令
 os.system :很简单的执行一条shell命令行
os.popen: 能连接到标准输入输出流,这样就可以实现命令的交互。用popen可以参考open()的用法,也是popen(commandStr),返回一个对象
 注意:在system使用时,Linux环境下在命令后+“&”才能实现并行执行命令,而在windows环境下,在命令前+“start”。
}}}
["source"]
= 待整理 =
{{{
#test_init.py
class test:
    def __init__(self):
        print "test.__init__"
        self.reset()
    def reset(self):
        print "test.reset()"
}}}
{{{
#dirive.py
from test_init import test
class dirive(test):
    def __init__(self):
        print "dirive.__init__"
        test.__init__(self)
    def reset(self):
        print "dirive.reset()"
Line 9: Line 43:
[:CategoryHomepage:{{{] if __name__ == "__main__":
    my_dirive = dirive()
#输出:
#dirive.__init__
#test.__init__
#dirive.reset()
}}}
如果dirive代码换成以下情况
{{{
#dirive.py
from test_init import test
class dirive(test):
    def reset(self):
        print "dirive.reset()"
Line 11: Line 58:
一、Python System Modules:

 . Sys与Os是python系统工具的核心,很多标准模块是从他们,原则上,sys导出与Python解释器相关的部件(例如模块的搜索路径),而os则包含了Python所运行的平台上的函数以及变量的映射。但这种界限比较模糊,例如标准的输入输出流是在Sys中的,它们明显是要和平台紧密联系的。
[:CategoryHomepage:}}}]
if __name__ == "__main__":
    my_dirive = dirive()
#输出:
#test.__init__
#dirive.reset()
}}}

一些零散笔记

Email: MailTo([email protected])


Python System Modules:

 . Sys与Os是python系统工具的核心,很多标准模块是从他们,原则上,sys导出与Python解释器相关的部件(例如模块的搜索路径),而os则包含了Python所运行的平台上的函数以及变量的映射。但这种界限比较模糊,例如标准的输入输出流是在Sys中的,它们明显是要和平台紧密联系的。

os Modules

os.curdir…….os.getcwd()//得到当前目录
        1、os.path模块
        提供了大量的关于目录的工具。例如:os.path.isdir()……isfile()……exists()…..getsize()….
……split()…..join()….basename()….dirname()……splittext()….. 
        2、在脚本文件中执行shell命令
        os.system :很简单的执行一条shell命令行
os.popen: 能连接到标准输入输出流,这样就可以实现命令的交互。用popen可以参考open()的用法,也是popen(commandStr),返回一个对象
        注意:在system使用时,Linux环境下在命令后+“&”才能实现并行执行命令,而在windows环境下,在命令前+“start”。

["source"]

待整理

#test_init.py
class test:
    def __init__(self):
        print "test.__init__"
        self.reset()
    def reset(self):
        print "test.reset()"

#dirive.py
from test_init import test
class dirive(test):
    def __init__(self):
        print "dirive.__init__"
        test.__init__(self)
    def reset(self):
        print "dirive.reset()"

if __name__ == "__main__":
    my_dirive = dirive()
#输出:
#dirive.__init__
#test.__init__
#dirive.reset()

如果dirive代码换成以下情况

#dirive.py
from test_init import test
class dirive(test):
    def reset(self):
        print "dirive.reset()"

if __name__ == "__main__":
    my_dirive = dirive()
#输出:
#test.__init__
#dirive.reset()

xiaobolee (last edited 2009-12-25 07:08:41 by localhost)