Python标准库参考概览

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

 

 

官方文档

200951711:38:08

开始研究Python的官方文档,越过基础教程,直接Library Reference

Built-in Functions介绍了Python的一些内置函数。

Built-in Constants则是FalseTure之类的几个变量。

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__']

 

后面就开始介绍各个内置的模块了。开始啃。

200951712:05:50

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值