博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python小技巧
阅读量:7007 次
发布时间:2019-06-27

本文共 3559 字,大约阅读时间需要 11 分钟。

hot3.png

使用

查看python的内置函数"BIF"

BIF内建函数可以自动导入到__main__命名空间,但是内建函数都有自己的命名空间——即__builtins__,因此我们可以通过Python shell,然后通过如下命令查看所有的BIF:

>>> dir(__builtins__)['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'BufferError', 'BytesWarning', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False', 'FloatingPointError', 'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError', 'ImportWarning', 'IndentationError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'LookupError', 'MemoryError', 'NameError', 'None', 'NotImplemented', 'NotImplementedError', 'OSError', 'OverflowError', 'PendingDeprecationWarning', 'ReferenceError', 'RuntimeError', 'RuntimeWarning', 'StandardError', 'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError', 'SystemExit', 'TabError', 'True', 'TypeError', 'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning', 'ValueError', 'Warning', 'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__', '__name__', '__package__', 'abs', 'all', 'any', 'apply', 'basestring', 'bin', 'bool', 'buffer', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile', 'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex', 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter', 'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'memoryview', 'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property', 'quit', 'range', 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', 'sorted', 'static method','str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']

然后,我们可以通过help(<object>)命令查看BIF内建函数的详细信息:

>>> help(range)Help on built-in function range in module __builtin__:range(...)    range(stop) -> list of integers    range(start, stop[, step]) -> list of integers        Return a list containing an arithmetic progression of integers.    range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.    When step is given, it specifies the increment (or decrement).    For example, range(4) returns [0, 1, 2, 3].  The end point is omitted!    These are exactly the valid indices for a list of 4 elements.(END)

查看python的模块放置在计算机的什么地方

打开python的命令行工具,输入命令:

>>> import sys; sys.path输出如下(mac环境下):['', '/Library/Python/2.7/site-packages/virtualenv-15.0.2-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']

Python的包管理器PyPI

是基于互联网的第三方Python模块存放的一个存储库。

转载于:https://my.oschina.net/u/658505/blog/754335

你可能感兴趣的文章
重读 Youtube 深度学习推荐系统论文,字字珠玑,惊为神文
查看>>
重磅!复宏汉霖首款产品汉利康®获批,成中国生物类似药里程碑
查看>>
kubernetes安装
查看>>
回首2018 | 分析型数据库AnalyticDB:不忘初心 砥砺前行
查看>>
SpringCloud API网关-Zuul
查看>>
宽凳科技公布最新进展:已完成百余座城市数据采集,即将发布首张全自动高精度地图...
查看>>
GraphQL 分享 理论篇
查看>>
抓取猫眼电影top100的正则、bs4、pyquery、xpath实现方法
查看>>
Zabbix 中文显示(学习笔记四)
查看>>
财报显示阿里云“可怕”之处 和AWS等全球头部云厂商还差多少?
查看>>
【对讲机的那点事】你知道吗?对讲机天线决定了对讲机的通信效果
查看>>
Android GreenDao常用注解
查看>>
二十分钟教你如何将区块链应用与函数计算相结合
查看>>
Bootstrap wysiwyg,将富文本数据保存到mysql
查看>>
Linux cron crontab用法(转载)
查看>>
Window 编译Openssl
查看>>
SAMBA 生产环境应用实例
查看>>
WPF - Group分组对ListBox等列表样式的约束
查看>>
Android 位置服务——BaiduLocation的使用
查看>>
源码专题之spring设计模式:单例模式
查看>>