python菜鸟学习: 10. 函数的基本用法
# -*- coding: utf-8 -*-
# 回参函数
def test01():
return 0
# 以元组返回参数
def test02():
return 1, [1, 2, 3, 4, 5], {"name": "liyuzhoupan"}
# 有参函数
def test03(x, y):
print(x)
print(y)
# 默认参数函数
def test03(x, y=2):
print(x)
print(y)
# 参数组: 接收位置参数(1,2,3,4,5,6,)
def test04(*args):
print(args)
# 字典参数:接收关键字参数x="name"
def test5(x, **kwargs):
print(x)
print(kwargs.keys())
test5(x=1, name="liyuzhoupan", age="26", level="1")
本文来自博客园,作者:鲤鱼洲畔,转载请注明原文链接:https://www.cnblogs.com/liyuzhoupan/p/16601827.html