`
king_tt
  • 浏览: 2083558 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Python 学习入门(33)—— 内置函数

 
阅读更多

python 的内置函数可以直接调用,无需import,常用到的有:

int()将字符串或者小数转换成整数

str()将其他类型转换是字符型

len(X)返回X的长度。The argument may be a sequence (string, tuple or list) or a mapping (dictionary).

print()输出

type(X)返回X的数据类型

open(f)打开一个文件f并返回文件类型的对象,和file()相似。

<wbr></wbr>

在python2.7.2 doc中可以查到每个函数的详细用法:function

Built-in Functions
abs() divmod() input() open() staticmethod()
all() enumerate() int() ord() str()
any() eval() isinstance() pow() sum()
basestring() execfile() issubclass() print() super()
bin() file() iter() property() tuple()
bool() filter() len() range() type()
bytearray() float() list() raw_input() unichr()
callable() format() locals() reduce() unicode()
chr() frozenset() long() reload() vars()
classmethod() getattr() map() repr() xrange()
cmp() globals() max() reversed() zip()
compile() hasattr() memoryview() round() __import__()
complex() hash() min() set() apply()
delattr() help() next() setattr() buffer()
dict() hex() object() slice() coerce()
dir() id() oct() sorted() intern()

想要查所有内置函数名可以在python命令行方式中如下输入

>>> 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', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']



参考推荐:

Built-in Functions(官方)

python的内置函数(built-in functions)

Python内置函数清单


分享到:
评论

相关推荐

    人工智能(机器学习基础)-Python内置函数(8)

    大家好,这是近期跑过的code,即人工智能(机器学习基础)——Python内置函数(8),已经在博客中记录。适用于大学生/研0学生,为Python基础code,包含具体的实际应用场景。欢迎有需要的朋友下载!结合专栏【Python...

    研0必学-人工智能(机器学习基础)Python内置函数(7)

    这是系列文章和资源:研0必学——人工智能(机器学习基础)Python内置函数(7),内容已经在博客中记录,建议结合博客专栏学习【Python从入门到人工智能】,效果会更加哦!

    Python学习手册(第3版)

    , 《Python学习手册(第3版)》包括:, 类型和操作——深入讨论Python主要的内置对象类型:数字、列表和字典等。, 语句和语法——在Python中输入代码来建立并处理对象,以及Python一般的语法模型。, 函数——Python...

    Python学习手册(第3版).pdf 高清有书签

    , 《Python学习手册(第3版)》包括:, 类型和操作——深入讨论Python主要的内置对象类型:数字、列表和字典等。, 语句和语法——在Python中输入代码来建立并处理对象,以及Python一般的语法模型。, 函数——Python...

    Python编程入门经典

    1.3 开始使用Python——字符串 6 1.3.1 字符串概述 6 1.3.2 为什么需要引号 6 1.3.3 为什么有3种类型的引号 7 1.3.4 使用print()函数 7 1.3.5 理解不同的引号 8 1.4 串联两个字符串 10 1.5 用不同的方法串联字符串 ...

    Python学习手册

    , 《Python学习手册(第3版)》包括:, 类型和操作——深入讨论Python主要的内置对象类型:数字、列表和字典等。, 语句和语法——在Python中输入代码来建立并处理对象,以及Python一般的语法模型。, 函数——Python...

    头歌Python入门之元组与字典

    1.元组的使用:元组与列表,创建元组,访问元组,修改元组,元组内置函数 len(tuple):计算元组中元素个数。 max(tuple):返回元组中元素的最大值。 min(tuple):返回元组中元素的最小值。 tuple(seq):将列表转换为元组...

    Python学习手册第3版

    《Python学习手册(第3版)》讲述了:Python可移植、功能强大、易于使用,是编写独立应用程序和脚本应用程序的...如果你准备探索Google和YouTube为什么选中了Python,《Python学习手册(第3版)》就是你入门的最佳指南。

    Python学习手册(第3版)

    Python学习手册(第3版)(来自豆瓣) 《Python学习手册(第3版)》讲述了:Python可移植、功能强大、易于使用,是...如果你准备探索Google和YouTube为什么选中了Python,《Python学习手册(第3版)》就是你入门的最佳指南。

    小甲鱼Python课后习题

    ·类型和操作——深入讨论python主要的内置对象类型:数字、列表和字典等。 ·语句和语法——在python中输入代码来建立并处理对象,以及python一般的语法模型。 ·函数——python基本的面向过程工具,用于组织代码和...

    Python入门——小甲鱼Day3( 列表基础 )

    6.列表内置函数 7.拷贝与赋值 0.列表分类 普通列表:menber = [ ‘小甲鱼’,‘小布丁’] 混合列表:member = [‘小甲鱼’,520,3.14159,[1,2,3]] 空列表: member = [ ] 1.列表中添加元素 append() extend...

    pyvector:此模块的目的是创建一种处理向量的方法,该方法尽可能接近内置函数,就像向量在Python中成为一种新型变量一样

    该模块的目的是创建一种处理向量的方法,该方法尽可能接近内置函数,就像向量在Python中成为一种新型的变量一样。 我尝试添加所有带有现有向量的操作以及所有可能的属性。 如果我忘记了什么,请告诉我,我将尝试实施...

Global site tag (gtag.js) - Google Analytics