
2009年5月17日11:38:08
开始研究Python的官方文档,越过基础教程,直接Library Reference。
Built-in Functions介绍了Python的一些内置函数。
Built-in Constants则是False、Ture之类的几个变量。
Built-in Types包含对内置类型的详细介绍。
Built-in Exceptions介绍了内置的异常。
文中介绍说exceptions不需要import就在命名空间中。不过我访问exceptions的时候报错:
>>> exceptions
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
exceptions
NameError: name 'exceptions' is not defined
>>> NameError
<type 'exceptions.NameError'>
>>>
报错信息中的NameError证明了异常确实在命名空间中,只是不能使用exceptions访问罢了。
>>> import exceptions
>>> dir(exceptions)
['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'DeprecationWarning', 'EOFError', 'EnvironmentError', 'Exception', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'WindowsError', 'ZeroDivisionError', '__doc__', '__name__']
后面就开始介绍各个内置的模块了。开始啃。
2009年5月17日12:05:50

本文记录了作者初次研读Python官方文档的经历,重点介绍了内置函数、常量、类型及异常等内容,并通过实践验证了异常处理机制的存在。

1334

被折叠的 条评论
为什么被折叠?



