摘要: 1. python中的try{}catch{}2. raise exception3. try...except ... else..4. finally块1. python中的try{}catch{}python中的异常处理的关键字和c#中的是不相同的,python中使用try,except关键在来处理异常,如下:defdive(x,y): try:result=x/y;exceptZeroDivisionErrorasz:print("divisionbyzero.",z);else:print("theresultis",result);final 阅读全文
posted @ 2011-04-30 21:28 qiang.xu 阅读(2125) 评论(0) 推荐(0) 编辑
摘要: '''Createdon2011-4-30@author:xuqiang'''#openfile#open(file,mode)#file:thefiletobeopened#mode:openfilemode,'r'thefilewillonlyberead#'w'onlywritingandexistingfilewiththesamenamewillbeerased#'a'opensthefileforappending#'r+'read&write#'b 阅读全文
posted @ 2011-04-30 20:50 qiang.xu 阅读(1375) 评论(0) 推荐(0) 编辑
摘要: 1. python模块简介及使用示例2. 模块的搜索路径3. 模块编译4. package简介及使用示例5. package的导入import 5.1 控制导出模块列表 5.2 相对导入和绝对导入<1>. python模块简介及使用示例1.1 python模块简介一个包含了python的定义definition和语句statement的文件称之为是一个module。每个module都默认含有一个全局变量__name__表示该模块的名字,同时可以使用如下的代码指定在命令行下运行该脚本文件时执行的语句。if__name__=="__main__":importsys 阅读全文
posted @ 2011-04-30 20:17 qiang.xu 阅读(1985) 评论(2) 推荐(0) 编辑