内置函数(Day16)

    现在python一共为我们提供了68个内置函数。它们就是python提供给你直接可以拿来使用的所有函数

  内置函数  
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()  
delattr() help() next() setattr()  
dict() hex() object() slice()  
dir() id() oct() sorted() exec 内置表达式

输入输出相关

input()  输入

print()  输出

数据类型相关

type(l) 返回变量l的数据类型

内存相关:

id(o) o是参数,返回一个变量的内存地址

hash(o) o是参数,返回一个可hash变量的哈希值,不可hash的变量被hash之后会报错。

t = (1,2,3)
l = [1,2,3]
print(hash(t))  #可hash
print(hash(l))  #会报错

'''
结果:
TypeError: unhashable type: 'list'
'''
View Code

hash函数会根据一个内部的算法对当前可hash变量进行处理,返回一个int数字。

*每一次执行程序,内容相同的变量hash值在这一次执行过程中不会发生改变。

文件操作相关

open()  打开一个文件,返回一个文件操作符(文件句柄)

操作文件的模式有r,w,a,r+,w+,a+ 共6种,每一种方式都可以用二进制的形式操作(rb,wb,ab,rb+,wb+,ab+)

可以用encoding指定编码.

详细的内置函数介绍可以参照以下https://www.rddoc.com/doc/Python-3.6.0/library/functions/

内置函数扩展用法可看以下链接:http://www.cnblogs.com/Eva-J/articles/7206498.html

有一种能力,是持续不断的努力
原文地址:https://www.cnblogs.com/shaojiafeng/p/7268964.html