摘要:
一、加法 def func(a,b): result = a+b return resolt ret = func(1,2) print(ret) ###输出3 二、判断传入的字符串是不是标题 def funcl (a) if a.istitle(): return True else: retur 阅读全文
摘要:
一、 def f1(*a): ##形参前加一个*号,实参可以给任意多个值都可以接收 print(a) f1(123,344) 二、 def f1(**a): ##形参必须传入字典形式 print(a) f1(k1=123,k2=344) 三、 def f1(*a,**aa): ##以上两种格式的实参 阅读全文
摘要:
def test(r,t,p) 形参 ret = test(p='等等',r='ere',t='csss') 实参,相等后位置上不用一一对应 默认值 def drive(name): temp = name +"开车" return temp ret = drive("一个人") print(ret 阅读全文
摘要:
def test(p): ##括号里接受参数 ,形式参数 print(p) return True ret = test('给参数p赋予的值‘) ##实际参数 if ret: print('成功') else: print('失败’) expect ###try中的代码出现错误,自动执行exexce 阅读全文
摘要:
def 创建函数的关键字 def test (): ##创建一个名字叫test的函数 print('Tom') ##此时并没有输出,因为函数内部代码不执行,当你调用函数的时候才执行 text()##此时调用函数,执行函数 返回值 def email(): print('我要发邮件') return 阅读全文