您的位置:首页 > 编程语言 > Python开发

python标准库

2015-10-26 15:35 585 查看
import copy
print [item for item in dir(copy) if not item.startswith('_')]
print "*"*50
for i in dir(copy):#查看模块包含的内容
print i
print "*"*50
print copy.__all__#定义模块公共接口 使用语句from copy import *将会倒入该语句打印出的函数函数
print "*"*50
print help(copy.copy)#获取帮助
print "*"*50
print range.__doc__#查找函数的描述
print "*"*50
print copy.__file__#文件路径
print "**********Done!Tada!!**********"

如上所示,可以对标准库进行一些查看,输出结果如下:

['Error', 'PyStringMap', 'copy', 'deepcopy', 'dispatch_table', 'error', 'name', 't', 'weakref']
**************************************************
Error
PyStringMap
...(省略若干行)
name
t
weakref
**************************************************
['Error', 'copy', 'deepcopy']
**************************************************
Help on function copy in module copy:

copy(x)
Shallow copy operation on arbitrary Python objects.

See the module's __doc__ string for more info.

None
**************************************************
range(stop) -> list of integers
range(start, stop[, step]) -> list of integers

Return a list containing an arithmetic progression of integers.
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
When step is given, it specifies the increment (or decrement).
For example, range(4) returns [0, 1, 2, 3]. The end point is omitted!
These are exactly the valid indices for a list of 4 elements.
**************************************************
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.pyc
**********Done!Tada!!**********下面简单介绍几个标准库:
第一个,踏哒,sys->这个模块让你能够访问于python解释器紧密联系的变量和函数

os模块提供了访问多个操作系统服务的功能

fileinput模块让你能够轻松的遍历文本文件的所有行

time模块:获得当前时间、操作时间和日期、从字符串读取日期以及格式化日期为字符串

radom模块包括返回随机数的函数

re模块包含对正则表达式的支持
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: