随笔分类 -  脚本语言

摘要:写一个Demo:大致7个部分:#1.起始行 #2.模块文档#3.模块导入#4.声明模块变量#5.类声明 #6.函数声明 #7.主程序 #!/usr/bin python #1"Here are module docs" #2import sys,os #3point = 20 ... 阅读全文
posted @ 2012-12-14 12:01 niewj 阅读(146) 评论(0) 推荐(0)
摘要:os模块跨平台os.linesep // '\r\n' windows '\r' POSIX系列os.sep // '\\' '/'os.pathsep // ';' ':'os.curdir // '.' os.par... 阅读全文
posted @ 2012-12-14 12:01 niewj 阅读(185) 评论(0) 推荐(0)
摘要:初学python之:python的全局变量测试def test1(): global line line=20*30 return linedef test2(): print line/0.1test1()test2() 结果为:6000.0可见:要在方法中共享全局变量,必须显式声明其为globa... 阅读全文
posted @ 2012-12-14 12:01 niewj 阅读(144) 评论(0) 推荐(0)
摘要:os模块:os.path.exists(path) -->bool #(path)文件或者目录存在os.path.abspath(path) -->str #(path)返回文件或者目录的绝对路径# 下面几个顾名思其义吧os.path.isfile(path) ... 阅读全文
posted @ 2012-12-14 12:01 niewj 阅读(150) 评论(0) 推荐(0)
摘要:python单元测试http://pyunit.sourceforge.net/pyunit_cn.html#JPYTHON 阅读全文
posted @ 2012-12-14 12:01 niewj 阅读(126) 评论(0) 推荐(0)
摘要:python基础:内置模块,用apply使用元祖和列表调用函数def my_fuc(a, b): print a, batuple=(30,10)alist= ['Hello','World!']apply(my_fuc,atuple)apply(my_fuc,alist)输出:D:\py>p... 阅读全文
posted @ 2012-12-14 12:01 niewj 阅读(1056) 评论(0) 推荐(0)
摘要:从今天起,多写些小例子,锻炼自己,从大家都不鸟的小段代码开始。今天弄一个从控制台输入信息,然后记录到当前路径下的一个固定文件中。很简单:import osfname=raw_input('Enter file name:')myf= open(fname,'w')while True: tex... 阅读全文
posted @ 2012-12-14 12:01 niewj 阅读(492) 评论(0) 推荐(0)