?? raising.py
字號(hào):
#!/usr/bin/env python# Filename: raising.pyclass ShortInputException(Exception): '''A user-defined exception class.''' def __init__(self,length,atleast): Exception.__init__(self) self.length=length self.atleast=atleasttry: s=raw_input('Enter something --> ') if len(s)<3: raise ShortInputException(len(s),3) # Other work can continue as usual hereexcept EOFError: print '\nWhy did you do an EOF on me?'except ShortInputException,x: print 'ShortInputException: The input was of length %d, \was expecting at least %d' %(x.length,x.atleast)else: print 'No exception was raised.'
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -