摘要: 1.使用IDLE的异常信息: try: data=open('missing.txt') print(data.readline(),end='') """为异常对象给定一个名,然后作为错误消息的一部分""" except IOError as err: """使用str()BIF要求异常对象表现为 阅读全文
posted @ 2017-07-21 18:06 秋水潺流 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 1.将打印出来到台词保存到文件中,需要如下步骤: 1)创建一个空列表,名为man 2)创建一个空列表,名为other 3)增加一行代码,删除spoken_line不必要到空白符 4)给出条件和代码,根据role的值将spoken_line添加到适当到列表中 5)在屏幕输出各个列表(man和other 阅读全文
posted @ 2017-07-21 15:46 秋水潺流 阅读(531) 评论(0) 推荐(0) 编辑
摘要: 1.错误处理 data=open('sketch.txt') for each_line in data: try: (role,spoken_line)=each_line.split(':',1) print(role,end='') print(' said:',end='') print(s 阅读全文
posted @ 2017-07-21 11:33 秋水潺流 阅读(193) 评论(0) 推荐(0) 编辑