笨办法学python3练习代码ex18.py
2021-04-15 03:28
标签:学python zed 接收 参数 意思 his fir this code 笨办法学python3练习代码ex18.py 标签:学python zed 接收 参数 意思 his fir this code 原文地址:https://www.cnblogs.com/lsc666js/p/13334702.html 1 #命名、变量、代码、函数
2 #this one is like your scripts with argv
3 def print_two(*args):
4 arg1, arg2 = args #将参数解包
5 print(f"arg1: {arg1}, arg2: {arg2}")
6 ‘‘‘
7 (*args) 里面*的意思:告诉Python把所有的参数都接收进来,放到名叫args的列表中去
8 ‘‘‘
9
10 #ok,that‘s *agrs is actually pointless(无意义的),we can just do this
11 def print_two_again(arg1, arg2):
12 print(f"arg1: {arg1}, arg2: {arg2}")
13
14 #this just takes one argument
15 def print_one(arg1):
16 print(f"arg1: {arg1}")
17
18
19 #this one takes no arguments
20 def print_none():
21 print("I got nothin‘.")
22
23
24 print_two("Zed","Shaw") #不带引号会出错,但是数字可以不带引号
25 print_two_again("Zed","Shaw")
26 print_one("First!")
27 print_none()
下一篇:多线程复习
文章标题:笨办法学python3练习代码ex18.py
文章链接:http://soscw.com/index.php/essay/75902.html