首页 > 编程语言 > 详细

python 函数

时间:2021-06-04 17:59:04      阅读:14      评论:0      收藏:0      [点我收藏+]
# 定义函数使用def
def test():
    """函数的注释"""
    print("hello python")

test()  # 调用函数 选中函数按ctrl + Q 可以查看函数注释
import hello  # 引入函数文件
hello.test()  # 调用引入的函数

 

# 传参
def test(num1,num2):
    a = num1+num2
    return a


result = test(10, 20)
print(result)
# 函数的嵌套
def test(char, times):
    print(char * times)


def test_s(num, char, times):
    """函数功能介绍
    
    :param num: 循环输出多少次
    :param char: 打印分割线使用的符号
    :param times: 打印多少次
    """
    row = 0
    while row < num:
        test(char, times)
        row += 1


test_s(10, "-", 20)

 

python 函数

原文:https://www.cnblogs.com/dazahui/p/14848735.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!