python基础学习笔记——Python基础教程(第2版 修订版)第五章(抽象)
#创建函数
def hello(name) return 'hello.'+name+'
#记录函数
def square(x) 'Calculate the squre of the number' return x*x squre._doc_
#参数
#字符串(数字,元组)不可变 #可变参数结构 def change(n): n[0]='sd' names=['dfe','eref',] change(names) ['sd','eref'] change(names[:])
#初始化数据结构
def init(data): data['first']={} data['second']={} data['last']={} storage={} init(storage) #字典没有具体顺序
#关键字参数
def hello(greeting,name) print('%s.%s‘%(greeting,name)) hello(greeting='world',greeting=’hello') def hello(greeting=‘hello',name=’world') heiilo('greeting') hello(name='ss')
#收集参数
def print_params(*params) #元祖 收集其余位置参数 def print_params(**params) print_params(x=1,y=2,z=32) {'x':1,'y':2,'z':32} #返回字典
#反转过程
#作用域
#递归
#二元查找