为什么“dir()"在python中被命名为“dir"? [英] Why is 'dir()' named 'dir' in python?

查看:31
本文介绍了为什么“dir()"在python中被命名为“dir"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Python 中有一个名为 dir 的内置函数.这用于获取对象的所有属性的列表.

In Python there is a built-in function called dir. This is used to get a list of all the attributes for an object.

我理解它的作用,但我对它为什么被称为 dir 感到困惑.这个名称与从对象中获取属性有什么关系?

I understand what it does, but I am confused about why it is called dir. How is this name related to getting the attributes from an object?

推荐答案

它为您提供了一个对象所有属性的目录目录.

It gives you a directory of all attributes of an object.

这不是文件系统中使用的目录,而是标准用法:名称或数据列表.

This is not a directory as used in file systems, but the standard usage: a listing of names or data.

这篇关于为什么“dir()"在python中被命名为“dir"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆