python中3个帮助函数help,dir,type的使用
来源:互联网 发布:活动发布网站源码 编辑:程序博客网 时间:2024/06/07 12:19
1 help函数:查看模块、函数、变量的详细说明:
- 查看模块
>>> help("modules")Please wait a moment while I gather a list of all available modules...BaseHTTPServer array htmllib setsBastion ast httplib sgmllibCDROM asynchat ihooks shaCGIHTTPServer asyncore imaplib shelveCanvas atexit imghdr shlexConfigParser audiodev imp shutilCookie audioop importlib signalDLFCN axi imputil siteDialog base64 inspect sitecustomizeDocXMLRPCServer bdb io smtpdFileDialog binascii itertools smtplib
- 查看包
>>> help("json")Help on package json:NAME jsonFILE /usr/lib/python2.7/json/__init__.pyMODULE DOCS http://docs.python.org/library/jsonDESCRIPTION JSON (JavaScript Object Notation) <http://json.org> is a subset of JavaScript syntax (ECMA-262 3rd edition) used as a lightweight data interchange format. :mod:`json` exposes an API familiar to users of the standard library :mod:`marshal` and :mod:`pickle` modules. It is the externally maintained version of the :mod:`json` library contained in Python 2.6, but maintains compatibility with Python 2.4 and Python 2.5 and (currently) has significant performance advantages, even without using the optional C extension for speedups. Encoding basic Python object hierarchies::
- 查看类
>>> help(json.JSONDecoder)Help on class JSONDecoder in module json.decoder:class JSONDecoder(__builtin__.object) | Simple JSON <http://json.org> decoder | | Performs the following translations in decoding by default: | | +---------------+-------------------+ | | JSON | Python | | +===============+===================+ | | object | dict | | +---------------+-------------------+ | | array | list | | +---------------+-------------------+ | | string | unicode | | +---------------+-------------------+ | | number (int) | int, long | | +---------------+-------------------+ | | number (real) | float | | +---------------+-------------------+ | | true | True | | +---------------+-------------------+ | | false | False |
- 查看函数:
>>> help(json.dump)Help on function dump in module json:dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, encoding='utf-8', default=None, **kw) Serialize ``obj`` as a JSON formatted stream to ``fp`` (a ``.write()``-supporting file-like object). If ``skipkeys`` is true then ``dict`` keys that are not basic types (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``) will be skipped instead of raising a ``TypeError``. If ``ensure_ascii`` is false, then the some chunks written to ``fp`` may be ``unicode`` instances, subject to normal Python ``str`` to ``unicode`` coercion rules. Unless ``fp.write()`` explicitly understands ``unicode`` (as in ``codecs.getwriter()``) this is likely to cause an error.
2 dir函数:查看变量可用的函数或方法
>>> 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', 'dont_write_bytecode', 'exc_clear', 'exc_info', 'exc_type', 'excepthook', 'exec_prefix', 'executable', 'exit', 'exitfunc', 'flags', 'float_info', 'float_repr_style', 'getcheckinterval', 'getdefaultencoding', 'getdlopenflags', 'getfilesystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof', 'gettrace', 'hexversion', 'last_traceback', 'last_type', 'last_value', 'long_info', 'maxint', 'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'py3kwarning', 'pydebug', 'setcheckinterval', 'setdlopenflags', 'setprofile', 'setrecursionlimit', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_info', 'warnoptions']
3 type函数:查看变量的类型
<type 'module'>>>> type (json.__name__)<type 'str'>>>> type (json.decoder)<type 'module'>
4 退出python命令行
windows: ctrl+z 回车
linux:ctrl+d
注:使用pydoc module 可查看模块的文档说明
0 0
- python中3个帮助函数help,dir,type的使用
- 用好Python帮助函数help(),dir(),type()
- Python 的帮助--help、dir、type
- Python函数---dir(),help(),type()
- Python中有用的三个工具:dir, type和help
- Python 寻求帮助dir,help
- 在命令行中查看python帮助文档 --dir、help、__doc__
- Python 查看帮助文档 dir(),help()
- python文档帮助help()和dir()
- Python中help() 与 dir()
- Python查看帮助---help函数
- Python查看帮助---help函数
- Python的type, str, dir和callable函数
- Python的dir函数
- Python的dir()函数
- matlab中dir()函数的使用
- 关于python中help函数的应用
- 如何在命令行模式下查看Python帮助文档---dir、help、__doc__
- 搭建淘宝Tair服务器
- 端口
- 【c++】PAT (Advanced Level) 1006. Sign In and Sign Out (25)
- 使用SqlCacheDependency类的操作流程
- hdu1104 Remaindr-----bfs+数论
- python中3个帮助函数help,dir,type的使用
- 对于疏于经营情感的情侣来说,时间才是最让人担心的小三
- 程序员编程艺术---5、寻找满足和为定值的两个或多个数
- 清理过期数据的存储过程
- 使用ez_setup.py安装setuptools报错
- Unknown Mozilla path (MOZILLA_FIVE_HOME not set
- 常用的邮箱类型
- 设计模式学习之简单工厂模式
- maven导出项目依赖的jar包