摘要: 15、更多Python的内容 (1)列表推导式 1 >>> #列表推导式 2 >>> listone=[2,3,4] 3 >>> listtwo=[2*i for i in listone if i>2] 4 >>> print listone 5 [2, 3, 4] 6 >>> print lis 阅读全文
posted @ 2018-02-01 11:03 七甲八甲 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 14、Python标准库 (1)sys模块 1 # -*- coding:utf-8 -*- 2 import sys 3 4 5 def readfile(filename): 6 """Print a file to the standard output.""" 7 f = file(file 阅读全文
posted @ 2018-02-01 10:43 七甲八甲 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 13、异常 (1)错误 程序中的一些无效语句,比如语法错误,如下所示: (2)try...except 可以使用try...except来处理异常 输出: (3)引发异常 可以使用raise语句 引发 异常。 还得指明错误/异常的名称和伴随异常 触发的 异常对象。 可以引发的错误或异常应该分别是一个 阅读全文
posted @ 2018-02-01 09:35 七甲八甲 阅读(191) 评论(0) 推荐(0) 编辑