我们如何引用以" __"开头的术语?在python中

时间:2017-03-08 07:28:01

标签: python python-2.7

我想知道在给出dir(sys)作为示例时列出的项目的术语。

将更清楚,我们将如何引用这些call_tracing或callstarts或版权。他们会被称为"方法"?我们如何知道该目录列表中存在的每个属性的用法?

>>>import sys
>>>dir(sys)

['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__stderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_current_frames', '_getframe', '_mercurial', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle', 'dont_write_bytecode', 'exc_clear', 'exc_info', 'exc_traceback', 'exc_type', 'exc_value', 'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info', 'float_repr_style', 'getcheckinterval', 'getdefaultencoding', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'gettrace', 'getwindowsversion', 'hexversion', 'last_traceback', 'last_type', 'last_value', 'long_info', 'maxint', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'py3kwarning', 'setcheckinterval', 'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions', 'winver']

1 个答案:

答案 0 :(得分:1)

通常,dir(...)命令将显示类中存在的所有属性的列表。例如sys模块具有属性'__displayhook__', '__doc__', '__excepthook__', '__name__', etc

如果我正确理解了您的问题,那么是的,在您的情况下,它们将被称为包含call_tracingcallstartscopyright方法的sys模块的方法。

有关类的每个属性的使用信息,您将不得不参考该模块的文档。您提到的sys模块可以找到here

有关dir()命令的详细信息,您可以阅读文档here