Dive in python Chapter4 实例
def info(object,spacing=10,collapse=1):
"""Print methods and doc strings.
Takes modules,class,list,dictionary,or string."""
methodList = [method for method in dir(object) if callable(getattr(object,method))]
processFunc=collapse and (lambda s:" ".join(s.split())) or (lambda s: s)
print "\n".join(["%s %s" %
(method.ljust(spacing),
processFunc(str(getattr(object,method).__doc__)))
for method in methodList])
if __name__=="__main__":
print info.__doc__
此函数的作用可以用来输出对应对象的操作方法:>>> from apihelper import inf>>> li=[]
>>> from apihelper import info
>>> li=[]
>>> info(li)
__add__ x.__add__(y) <==> x+y
__class__ list() -> new empty list list(iterable) -> new list initialized from
iterable's items
__contains__ x.__contains__(y) <==> y in x
__delattr__ x.__delattr__('name') <==> del x.name
__delitem__ x.__delitem__(y) <==> del x[y]
__delslice__ x.__delslice__(i, j) <==> del x[i:j] Use of negative indices is not
supported.
__eq__ x.__eq__(y) <==> x==y
__format__ default object formatter
__ge__ x.__ge__(y) <==> x>=y
__getattribute__ x.__getattribute__('name') <==> x.name
__getitem__ x.__getitem__(y) <==> x[y]
__getslice__ x.__getslice__(i, j) <==> x[i:j] Use of negative indices is not sup
ported.
__gt__ x.__gt__(y) <==> x>y
__iadd__ x.__iadd__(y) <==> x+=y
__imul__ x.__imul__(y) <==> x*=y
__init__ x.__init__(...) initializes x; see help(type(x)) for signature
__iter__ x.__iter__() <==> iter(x)
__le__ x.__le__(y) <==> x<=y
__len__ x.__len__() <==> len(x)
__lt__ x.__lt__(y) <==> x<y
__mul__ x.__mul__(n) <==> x*n
__ne__ x.__ne__(y) <==> x!=y
__new__ T.__new__(S, ...) -> a new object with type S, a subtype of T
__reduce__ helper for pickle
__reduce_ex__ helper for pickle
__repr__ x.__repr__() <==> repr(x)
__reversed__ L.__reversed__() -- return a reverse iterator over the list
__rmul__ x.__rmul__(n) <==> n*x
__setattr__ x.__setattr__('name', value) <==> x.name = value
__setitem__ x.__setitem__(i, y) <==> x[i]=y
__setslice__ x.__setslice__(i, j, y) <==> x[i:j]=y Use of negative indices is no
t supported.
__sizeof__ L.__sizeof__() -- size of L in memory, in bytes
__str__ x.__str__() <==> str(x)
__subclasshook__ Abstract classes can override this to customize issubclass(). T
his is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return Tru
e, False or NotImplemented. If it returns NotImplemented, the normal algorithm i
s used. Otherwise, it overrides the normal algorithm (and the outcome is cached)
.
append L.append(object) -- append object to end
count L.count(value) -> integer -- return number of occurrences of value
extend L.extend(iterable) -- extend list by appending elements from the iter
able
index L.index(value, [start, [stop]]) -> integer -- return first index of v
alue. Raises ValueError if the value is not present.
insert L.insert(index, object) -- insert object before index
pop L.pop([index]) -> item -- remove and return item at index (default la
st). Raises IndexError if list is empty or index is out of range.
remove L.remove(value) -- remove first occurrence of value. Raises ValueErro
r if the value is not present.
reverse L.reverse() -- reverse *IN PLACE*
sort L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*;
cmp(x, y) -> -1, 0, 1
Dive in python Chapter4 实例的更多相关文章
- Dive in python Chapter3 实例
def buildConnectionString(params): """Build a connection string from a dictionary Ret ...
- python 学习笔记 5 ----> dive into python 3
字符串 文本:屏幕上显示的字符或者其他的记号 计算机认识的东西:位(bit)和字节(byte) 文本的本质:某种字符编码方式保存的内容. 字符编码:一种映射(显示的内容 ----> 内存.磁盘 ...
- python 学习笔记 2 ----> dive into python 3
Python Shell idle的使用 >>> >>>help() ----> help> 可以在help这个工具中查找Python内置函数的文档等等 ...
- python基础——实例属性和类属性
python基础——实例属性和类属性 由于Python是动态语言,根据类创建的实例可以任意绑定属性. 给实例绑定属性的方法是通过实例变量,或者通过self变量: class Student(objec ...
- python 发送邮件实例
留言板回复作者邮件提醒 -----------2016-5-11 15:03:58-- source:python发送邮件实例
- python Cmd实例之网络爬虫应用
python Cmd实例之网络爬虫应用 标签(空格分隔): python Cmd 爬虫 废话少说,直接上代码 # encoding=utf-8 import os import multiproces ...
- 为什么《Dive into Python》不值得推荐
2010 年 5 月 5 日更新:我翻译了一篇<<Dive Into Python>非死不可>作为对本文观点的进一步支持和对评论的回复,请见:http://blog.csdn. ...
- Python爬虫实例:爬取B站《工作细胞》短评——异步加载信息的爬取
很多网页的信息都是通过异步加载的,本文就举例讨论下此类网页的抓取. <工作细胞>最近比较火,bilibili 上目前的短评已经有17000多条. 先看分析下页面 右边 li 标签中的就是短 ...
- Python爬虫实例:爬取猫眼电影——破解字体反爬
字体反爬 字体反爬也就是自定义字体反爬,通过调用自定义的字体文件来渲染网页中的文字,而网页中的文字不再是文字,而是相应的字体编码,通过复制或者简单的采集是无法采集到编码后的文字内容的. 现在貌似不少网 ...
随机推荐
- Salesforce删除数据时出现Insufficient privileges的可能原因
遇到一个诡异的情况,用户通过界面删除一条自定义Object的数据的时候出现了Insufficient privileges.按理说,如果用户的Profile没有此Object的删除权限的话,应该连删除 ...
- 蓝牙连接音响问题(android电视)
最近老大让我开发电视的蓝牙,由于android电视的蓝牙不稳定和设计上的各种各样的要求,需要在原有的基础上做一些更改,中间遇到了各种问题,在此总结一下. 我们首先要获取blueToothAdapter ...
- 使用net Manager工具远程连接oracle
一,在服务端配置oracle端口 在命令行中输入netca命令,打开相关配置默认端口号为1521 二,配置端口后使用Telnet工具调试端口是否联通 在命令行输入telnet 服务器ip 端口号 三, ...
- java中静态代码块,构造代码块,以及构造方法的执行顺序
写了许久的代码,却把一些基础的东西都给忘了,今天无聊就顺手写了个,然后测试下,发现跟我记忆中的竟然有些出入,作为一个两年的开发,我感觉自己很失败啊. 父类pojo: public class Pojo ...
- pod install 报错
更新pod出现如下警告 The `SmartCloud_TS [Debug]` target overrides the `GCC_PREPROCESSOR_DEFINITIONS` build se ...
- jwplayer 限制拖动事件 快进 快退
开源精神不是ctrl +c + ctrl+v 谢谢 最近项目需要视频播放不能拖动,我已经实现即不能向前拖动,也不能向后拖动, 方法:打开用记事本 或者notepad 工具打开 jwpla ...
- 利用CSS3 animation绘制动态卡通人物,无需使用JS代码
此外博主原创,转载请注明出处:谢谢~ 效果图: 其中云.风车.尾巴是动态的: 以下是代码: <!DOCTYPE html> <html lang="en"> ...
- QQ微信刷屏助手 FlashScreenAssist 1.2发布
主要功能 文字刷屏 图片刷屏 简易教程 文字刷屏 打开软件之后输入要刷屏的文字,点击[开始],然后点一下微信或者QQ的输入框,就会开始刷屏了,注意[时间间隔]不要调太小,越小越快. 要注意的是.必须在 ...
- 在Signalr的Hub中写方法实现与安卓的数据交互
简介: 实现数据实时刷新:SignalR 后台服务:.NET/WebAPI 为了减轻web的压力,将接口中接收数据的方法写到SignalR的Hub中 在此放一小段代码给自己加深下印象,博主有点健忘.. ...
- 关于hession 随笔
今天遇到一个问题,纠结了很久也没有解决,情况是这样的, 我这个项目使用的是 hession 通信.我做的业务很简单,只是新加了一个接口 ,这 个接口是广告那一块的,数据库在之前的项目里面都没有使用到 ...