[Python] Find available methods and help in REPL
For example you want to know what methods are available in Python for String, you can do :
dir("xxx")
Output:
>>> dir("string")
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
Now for example, we want to see How to use 'swapcase' method:
help("foo".swapcase)
It will show example and description about the method, which is very useful
[Python] Find available methods and help in REPL的更多相关文章
- Python笔记 #04# Methods
源:DataCamp datacamp 的 DAILY PRACTICE + 日常收集. Methods String Methods List Methods 缺一 Methods You can ...
- A Guide to Python's Magic Methods
Book Source:[https://rszalski.github.io/magicmethods/] magic methods: 名称前后有双下划线的方法 构造函数和初始化 初始化类实例时, ...
- Python 的 Magic Methods 指南(转)
介绍 本指南是数月博客的总结.主题是魔术方法. 什么是魔术方法呢?它们是面向对象Python语言中的一切.它们是你可以自定义并添加“魔法”到类中的特殊方法.它们被双下划线环绕(比如__init__或_ ...
- python的magic methods
https://pycoders-weekly-chinese.readthedocs.io/en/latest/issue6/a-guide-to-pythons-magic-methods.htm ...
- Understanding Python metaclasses
转载:https://blog.ionelmc.ro/2015/02/09/understanding-python-metaclasses/ None of the existing article ...
- fw:学好Python必读的几篇文章
学好Python必读的几篇文章 from:http://blog.csdn.net/hzxhan/article/details/8555602 分类: python2013-01-30 11:52 ...
- Data manipulation primitives in R and Python
Data manipulation primitives in R and Python Both R and Python are incredibly good tools to manipula ...
- 理解Python元类(转)
add by zhj:先收藏了,有时间看,图倒是不少,可以配合stackover flow上那篇文章一起看 原文:http://blog.ionelmc.ro/2015/02/09/understan ...
- A few things to remember while coding in Python.
A few things to remember while coding in Python. - 17 May 2012 - UPDATE: There has been much discuss ...
随机推荐
- thinkphp5项目--个人博客(六)
thinkphp5项目--个人博客(六) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- [GDKOI2010] 圈地计划(网络流)
题2链接:https://www.luogu.org/problemnew/show/P1935 Description 最近房地产商GDOI(Group of Dumbbells Or Idiots ...
- Spring深入浅出(四)AOP面向切面
面向切面编程--AOP AOP(Aspect Oriented Programming),程序员称之为面向切面编程,是Spring框架除了IOC之外的另一个核心概念. AOP是对OOP(面向对象编程) ...
- css常用的阴影
一.box-shadow: 0 2px 15px 0 rgba(0,0,0,.15)!important 二. box-shadow: 0 2px 6px 0 rgba(0,0,0,.4); 三. . ...
- UWP开发小结
做了两天的UWP开发,上手还是挺快的,不过比较郁闷的是总会被一些很简单的细节卡住很久. 首先当然是用C#修改xaml界面这个难点了,Bing搜了好久都没找到相关信息,最后还是老司机伟神指点的我.对于g ...
- bzoj 2287: 【POJ Challenge】消失之物 动态规划
Code: #include<cstdio> #include<algorithm> #include<queue> #include<cstring> ...
- python 代码编写规范
一 代码编排1 缩进.4个空格的缩进(编辑器都可以完成此功能),不使用Tap,更不能混合使用Tap和空格.2 每行最大长度79,换行可以使用反斜杠,最好使用圆括号.换行点要在操作符的后边敲回车.3 类 ...
- iOS开发——设置屏幕亮度
想在APP里面调节屏幕的亮度,这只是个小众需求.而且,虽然可以直接调节手机的亮度,但是它还是个需求,客户有需求,剩下的就是我们的事了,好了,吐槽到此结束. 刚拿到这个需求的人,或许想的是直接对view ...
- 使用PXE+NFS EFI引导安装RHEL6/7以及Kickstart安装
PXE引导的步骤: 1.开机后选择网络启动,client端向server端的dhcpd发起获取IP地址的dhcp请求. 2.server端分配IP后,dhcpd会同时根据其配置文件,通过TFTP协议发 ...
- Unity 获得视频的某一帧,生成缩略图
Unity 并无直接获取视频某一帧图像的API,所以想要生成缩略图就要自己写方法了, 图片和视频都可以用这种方式生成缩略图,另,转载请标明出处,谢谢. using System.Collections ...