首页 > 编程语言 >Python内置方法

Python内置方法

时间:2023-01-04 17:56:54浏览次数:64  
标签:__ 内置 Python list python 方法 dir

开胃菜(小例子、用法):

help(method)

查看帮助,按space或enter继续显示多的行数(-- More --),按ctrl+c退出。
如果想要查看有哪些方法,比如list有哪些方法,可以:

dir(list)

输出:

>>> dir(list) 
['__add__', '__class__', '__contains__', 
'__delattr__', '__delitem__', '__dir__', 
'__doc__', '__eq__', '__format__', 
'__ge__', '__getattribute__', 
'__getitem__', '__gt__', '__hash__', 
'__iadd__', '__imul__', '__init__', 
'__init_subclass__', '__iter__', '__le__', 
'__len__', '__lt__', '__mul__', '__ne__', 
'__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__reversed__', '__rmul__', 
'__setattr__', '__setitem__', 
'__sizeof__', '__str__', 
'__subclasshook__', 'append', 'clear', 
'copy', 'count', 'extend', 'index', 
'insert', 'pop', 'remove', 'reverse', 
'sort']     

为什么len()在python中不是一个普通的方法?

来自流畅的python第一章

python还有哪些内置方法/函数?

image

python官方文档-内置函数:https://docs.python.org/zh-cn/3/library/functions.html
慢慢探索吧

标签:__,内置,Python,list,python,方法,dir
From: https://www.cnblogs.com/ltymaster/p/17025594.html

相关文章