# -*- coding: UTF-8 -*- # def foo2(prot=3306): # 默认参数 # print(prot) # foo2() # foo2(8080) # 位置参数 # foo2(prot=90) # 关键字参数 # def foo(name, age=19): # print(name) # return age, 20 # r = foo('xdc') # print(r) # def myfunc(x,y,z): # print(x,y,z) # tuple_vec = (1,0,10) # dict_vec = {'x':1, 'y':0, 'z':1 } # # myfunc(1,2,3) # 实参中的形参 # # myfunc(z=3,x=1,y=2) #关键字参数传 # myfunc(*tuple_vec) # 解包传 # myfunc(**dict_vec) # 解包传 (值必须对应) # def foo(name, age, *args): # arge 是动态参数(必须是位置参数) # # 动态参数就是传入的参数的个数是动态的,可以是1个、2个到任意个,还可以是0个 # print(name) # print(args) # foo('xdc',18) # foo('xdc', 18, 'a','b',[1,2,3]) # def func(**kwargs): # 可以是0个或多个, 字典类型 (关键值参数) # # 而**kwargs则是将一个可变的关键字参数的字典传给函数实参 # print(kwargs) # func(a=1,b=2,ip='192.168.10.102') ###============ split ============### astr = "hello world ,hhhh world heihei" def myreplace (astr,oldstr,newstr): result=astr.split(oldstr) return newstr.join(result) print(myreplace(astr,"world","job"))