Handling Exceptions: Asks the user for input until a valid integer has been entered,handlingexceptions,while True:
Handling Exceptions: Asks the user for input until a valid integer has been entered,handlingexceptions,while True:
while True: try: x = int(raw_input('Please enter a number: ')) break except ValueError: print 'Oops! That was no valid number. Try again...'
相关内容
- Math: pi and e,mathpiand,import mathp
- Max function,maxfunction,print max(2,
- Mod in Python,modinpython,print '107 %
- Thread.exit: spawn threads to watch shared global memory change;,th
- Synchronize stdout access to avoid multiple prints on 1 line,,impor
- Structure of a Program to Process a Document with a _DTD Using SAX,
- Caching Node Lookups,cachinglookups,def loadGram
- Every Element Is Searchable,elementsearchable,from xml.dom
- Searching for XML Elements,searchingelements,from xml.dom
- Processing XML with Regular Expressions,regularexpressions,import s
评论关闭