dir
dir可以帮助你认识任何数据类型,进行操作,并返回列表内建方法和数值。
help(dir())
返回dir()中的方法,及使用
help(dir())
| Raises IndexError if list is empty or index is out of range.
|
| remove(self, value, /)
| Remove first occurrence of value.
|
| Raises ValueError if the value is not present.
|
| reverse(self, /)
| Reverse IN PLACE.
|
| sort(self, /, *, key=None, reverse=False)
| Stable sort IN PLACE.
Static methods defined here: |
new(*args, **kwargs) from builtins.type |
Create and return a new object. See help(type) for accurate signature. |
example
>>> 'cat, dog, horse'.split(',')
['cat', ' dog', ' horse']
>>> animals = ['cat', ' dog', ' horse']
>>> animals.sort()
>>> print(animals)
[' dog', ' horse', 'cat']
>>> print(animals)
['cat', ' horse', ' dog']
>>> dir()
['__annotations__', '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__', 'animals']
>>> help(dir())