Python 官方文档:入门教程 => 点击学习
def cheeseshop(kind,*arguments,**keyWords): print("-- Do you have any",kind,"?") print("-- I'm sorry, we're all
def cheeseshop(kind,*arguments,**keyWords):
print("-- Do you have any",kind,"?")
print("-- I'm sorry, we're all out of",kind)
for arg in arguments:
print(arg)
print("-"*40)
keys = sorted(keywords.keys())
for kw in keys:
print(kw,":",keywords[kw])
f={"client":"John","sketch":"cheese"}
cheeseshop("Limburger","aaaaaaa","bbbbbbbbbb",**f)
cheeseshop("Limburger","aaaaaaa","bbbbbbbbbb",client="John",sketch="cheese")
功能一样,可见**args 时应为字典类型,或是关键字类型的参数。
--结束END--
本文标题: python函数的参数形式[]1]
本文链接: https://www.lsjlt.com/news/183152.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0