首页 > 编程语言 > 详细

Learn Python From 'Head First Python' [3] : Exception

时间:2014-09-09 11:28:28      阅读:279      评论:0      收藏:0      [点我收藏+]

1.the using of exception

2.file opration

import os
>>> try:
    data = open(sketch.txt)
    for each in data:
        try:
            (role,message) = each.split(:)
            print(role +  says:  + message, end=‘‘)
        except ValueError:
            pass
    data.close()
except IOError:
    print(file is missing)

you can get the sketch.txt from the python offical webstatie

Learn Python From 'Head First Python' [3] : Exception

原文:http://www.cnblogs.com/zhuojiniao/p/3961659.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!