摘要:
1、原始函数 def a(x,y): while x: temp = x.pop() print(f"printing model:{temp}") y.append(temp) def b(x): print("\nThe following model had been printed!") f 阅读全文
posted @ 2021-03-10 17:38
小鲨鱼2018
阅读(276)
评论(0)
推荐(0)
摘要:
1、不使用函数: list1 = ["aaaa","bbbb","cccc"] list2 = [] while list1: temp = list1.pop() print(f"printing model {temp}") list2.append(temp) print("\nThe fol 阅读全文
posted @ 2021-03-10 16:52
小鲨鱼2018
阅读(266)
评论(0)
推荐(0)
摘要:
1、 python中向函数传递列表,提高处理列表的效率。 >>> def a(x): ## 定义函数的形参x为可迭代对象 for i in x: print(f"hello,{i.title()}") >>> b = ["aaa","bbb","ccc","ddd"] ## 实参定义为列表,实现向函 阅读全文
posted @ 2021-03-10 15:22
小鲨鱼2018
阅读(487)
评论(0)
推荐(0)
摘要:
1、 >>> def a(first,meddle,last): b = f"{first} {meddle} {last}" return b.title() >>> a("aaa","bbb","ccc") 'Aaa Bbb Ccc' >>> a("aaa","bbb") ## 少一个实参报错 阅读全文
posted @ 2021-03-10 11:26
小鲨鱼2018
阅读(71)
评论(0)
推荐(0)
摘要:
1、 >>> def a(x,y): b = {"key1":x,"key2":y} return b >>> a(111,222) {'key1': 111, 'key2': 222} >>> a(111,222,333) ## 多家实参报错 Traceback (most recent call 阅读全文
posted @ 2021-03-10 11:12
小鲨鱼2018
阅读(378)
评论(0)
推荐(0)
摘要:
1、 def a(first,last): full = f"{first} {last}" return full.title() while True: ## 条件为真的话,一直循环 print("\n\nplease tell me your name:") ## 两个\n,每执行一次循环,空 阅读全文
posted @ 2021-03-10 10:33
小鲨鱼2018
阅读(363)
评论(0)
推荐(0)

浙公网安备 33010602011771号