3.4_函数_Function_Part_2
【摘要】
默认参数
关键字参数
VarArgs参数
Code:
#-*- coding: utf-8 -*-
# 默认参数
def repeat_str(s, times = 1):
repeated_strs...
repeated_strings = repeat_str("Happy Birthday!")
repeated_strings_2 = repeat_str("Happy Birthday!" , 4)
Happy Birthday!Happy Birthday!Happy Birthday!Happy Birthday!
print('a is', a, 'and b is', b, 'and c is', c)
a is 13 and b is 17 and c is 8
a is 125 and b is 4 and c is 24
a is 80 and b is 4 and c is 40
def print_paras(fpara, *nums, **words):
print_paras("hello", 1, 3, 5, 7, word = "python", anohter_word = "java")
words: {'word': 'python', 'anohter_word': 'java'}
def print_paras(fpara, *nums, **words):
文章来源: hiszm.blog.csdn.net,作者:孙中明,版权归原作者所有,如需转载,请联系作者。
原文链接:hiszm.blog.csdn.net/article/details/77800298
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)