【python3】快速上手(4) : 函数

#定义函数 那么def 就是 define的缩写了

#实现

def function():

    print('hello world')

#调用

function()


#参数

def name(username):

    print(username)

name("zack")

#返回简单值

def full_Name(first_name,last_name):

    full_Names = first_name + last_name

    return full_Names

funll = full_Name("qiao","chao")

print(funll)

#传递列表

def greet_user(names):

    for name in names:

        msg = "hello" + name.title() +"!"

        print(msg)

names = ["1","2","3"]

greet_user(names)

发布了283 篇原创文章 · 获赞 21 · 访问量 20万+

猜你喜欢

转载自blog.csdn.net/dangbai01_/article/details/103475930