- 浏览: 64814 次
- 性别:
- 来自: 沈阳
文章分类
最新评论
dir()函数
dir()函数,能够显示一个模块定义的所有成员。
>>> import fibo, sys >>> dir(fibo) ['__name__', 'fib', 'fib2'] >>> dir(sys) ['__displayhook__', '__doc__', '__excepthook__', '__name__', '__stderr__', '__stdin__', '__stdout__', '_getframe', 'api_version', 'argv', 'builtin_module_names', 'byteorder', 'callstats', 'copyright', 'displayhook', 'exc_info', 'excepthook', 'exec_prefix', 'executable', 'exit', 'getdefaultencoding', 'getdlopenflags', 'getrecursionlimit', 'getrefcount', 'hexversion', 'maxint', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setdlopenflags', 'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'version', 'version_info', 'warnoptions']
如果dir()中不写参数,就表示它显示的是当前模块的成员。
>>> a = [1, 2, 3, 4, 5] >>> import fibo >>> fib = fibo.fib >>> dir() ['__builtins__', '__doc__', '__file__', '__name__', 'a', 'fib', 'fibo', 'sys']
如果要显示内建的模块,要加参数“builtins”
>>> import builtins >>> dir(builtins) ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'Buffer Error', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'Environme ntError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'Generato rExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexErr or', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'P endingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', ' StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'Ta bError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'Unicod eEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserW arning', 'ValueError', 'Warning', 'ZeroDivisionError', '__build_class__', '__deb ug__', '__doc__', '__import__', '__name__', '__package__', 'abs', 'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'chr', 'classmethod', 'compile', ' complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate ', 'eval', 'exec', 'exit', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memory view', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property' , 'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sort ed', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars', 'zip']
发表评论
-
django-admin.py startproject mysite 不成功
2012-02-27 11:30 1979我在执行 django-admin.py startproj ... -
python学习笔记---迭代器
2012-02-03 15:58 0d -
python笔记---反射
2012-02-03 15:41 926java反射到学过,python反射没用过。这里几下别人的文章 ... -
python学习笔记---类
2012-02-03 12:58 1035类 和其他语言比较,python添加一个class使用 ... -
python学习笔记---输出格式化
2012-02-02 15:14 0输出格式化 目前为止,我们有2中方式去写一个值。表达式语句和 ... -
python笔记---包
2012-02-02 11:57 943包是一种结构化python模块的一种方法。 文件结构如下: ... -
python笔记---标准模块
2012-02-02 11:29 870标准模块 python带有标准模块库。他们一般在pyt ... -
python学习笔记---"编译python文件"
2012-02-02 11:15 0为了快速的导入一个程序文件,这里在spam.py所在的目录下就 ... -
python笔记---模块搜索路径
2012-02-02 10:34 1630模块搜索路径 当一个名为spam的模块被载入的时候,解释器会 ... -
python学习笔记---模块
2012-02-02 10:07 1109模块 一个模块不但包含语句,还包含函数的定义。这些语句是用来 ... -
python学习笔记---序列的比较
2012-02-01 22:20 762序列的比较 序列对象可以和同类型的其他对象进行比较。根 ... -
python笔记---集合后的更多条件操作
2012-02-01 18:51 1330除了比较运算符,while和if语句中还可以使用更多的操作符。 ... -
python笔记---集合迭代技术
2012-02-01 18:07 1307>>> basket = ['apple', ... -
python学习笔记---字典
2012-02-01 17:47 1033字典 字典不像序列是被数字索引的,字典是被关键字索引的 ... -
python笔记---sets
2012-02-01 17:13 9165.4.Sets python还包含一个数据类型sets。s ...
相关推荐
问答互动引出学习目标 讲授法 示范练习 随堂报告 Python-Python函数-教学设计全文共6页,当前为第1页。Python-Python函数-教学设计全文共6页,当前为第1页。《Python函数》教学设计 Python-Python函数-教学设计全文...
Python学习笔记--皮大庆,非常适合零基础入门。对应英文版本《How to think like a computer scientist》
python笔记-学习python基础-01,学习第一个python程序,好好学习天天向上
python爬虫学习笔记-scrapy框架(1) python scrapy 爬虫 python爬虫学习笔记-scrapy框架(1) python scrapy 爬虫 python爬虫学习笔记-scrapy框架(1) python scrapy 爬虫 python爬虫学习笔记-scrapy框架(1) python ...
强烈推荐《How to think like a computer scientist》,对应中文版本《Python学习笔记--皮大庆》,非常适合零基础入门。
Python学习笔记--皮大庆
Python学习笔记--笔记2
统计学习方法笔记-基于Python算法实现源码.zip 统计学习方法笔记-基于Python算法实现源码.zip 统计学习方法笔记-基于Python算法实现源码.zip 统计学习方法笔记-基于Python算法实现源码.zip 统计学习方法笔记-基于...
引 言对象与型式关系函数及其参数代码简洁性四、结 论 提 纲 3 917361-Python教学-8-乔林-Python程序设计课程教学刍议-4月22日下午全文共78页,当前为第3页。 Python 程序设计课程教学刍议 4 917361-Python教学-...
Python学习笔记-
python学习笔记,包含一般函数-向量化函数-二元运算-ufunc对象
Python基础入门教程,适合Python初学者,文档内容包括, 目录 前言 i 第一章 程序 1 1.1 程序 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 什么是调试 . . . . . . . . . . . . . . . ....
思维导图梳理Python学习笔记(三)基础语法、数据类型部分。供学习参考,仅适合初学者。大佬请绕行
本人从7月底的python零基础到8月中旬学完python基础知识的所有笔记大汇总!Wrod文档严谨分一到四级标题;各个部分的条理全网第一清晰!可以自学也可以当工具书,欢迎参考!
《Architecture Patterns with Python-2020》-英文版 笔记 Harry Percival and Bob Gregory 《Architecture Patterns with Python-2020》-英文版 笔记 Harry Percival and Bob Gregory 《Architecture Patterns with...
Python--学习笔记
python3.5-64位官方安装包(Windows版本)下载,欢迎大家下载。
python字典-15-函数的总结.ev4.rar
整理总结了Python语言函数的定义,类与对象的定义与使用,Python数据类型转换函数,random函数,判断输入是否为数字判断相关函数,Python取整的方式,常见的Python的数学函数,时间日期相关函数,以及Python的一种...