[Python] Find available methods and help in REPL
Python in and Find available methods help
2023-09-14 09:00:51 时间
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机器学习(34)
- python re.compile() 详解——Python正则表达式「建议收藏」
- python整除和取余写法_Python的整除和取余[通俗易懂]
- 【说站】python列表清除元素的四种方式
- PYTHON主机_我的Python世界PDF
- python django 数据库_Apache+Mysql+PHP/Python简单项目
- Python 制作天眼查小程序
- python, 解决:WARNING: Running pip as the 'root' user can result in broken permissions and conflicti...
- python-Python与SQLite数据库-处理SQLite查询结果(一)
- python-Python与MongoDB数据库-使用Python执行MongoDB查询(三)
- Python Web 深度学习实用指南:第三部分
- python实现将excel数据添加到mongodb详解编程语言
- python在windows下实现ping操作并接收返回信息详解编程语言
- python在windows命令行下输出彩色文字代码详解编程语言
- 表★★ MySQL索引优化:IN表的应用(mysql索引in)
- 使用Python和Tesseract来识别图形验证码
- 简易Python Selenium爬虫实现歌曲免费下载
- 利用Oracle中IN运算符的优势(oracle中in的作用)
- MySQL中的Out和In操作一个简单的指南(mysql中out in)
- 限制解除Oracle中IN语句数量限制(oracle中in的数量)
- Python中捕捉详细异常信息的代码示例