摘要:
python中函数可以返回任何类型的值,包含列表和字典等较复杂的数据结构。 1、 >>> def fun(first,last,age): full = {"first":first,"last":last,"age":age} ## 函数返回列表 return full >>> infor = f 阅读全文
posted @ 2021-03-09 22:46
小鲨鱼2018
阅读(2356)
评论(0)
推荐(0)
摘要:
1、 >>> def a(first,middle,last): ## 函数定义了三个形参 full = f"{first} {middle} {last}" return full.title() >>> name = a("aaa","bbb","ccc") >>> print(name) Aa 阅读全文
posted @ 2021-03-09 22:11
小鲨鱼2018
阅读(159)
评论(0)
推荐(0)
摘要:
1、 >>> def a(x,y,z): print(x + y + z) >>> a(2,3,4) 9 >>> a(2,3) ## 缺少对应的实参 Traceback (most recent call last): File "<pyshell#317>", line 1, in <module 阅读全文
posted @ 2021-03-09 11:40
小鲨鱼2018
阅读(94)
评论(0)
推荐(0)