首页 > 编程语言 > 详细

笨办法学python3练习代码ex18.py

时间:2020-07-18 14:23:37      阅读:50      评论:0      收藏:0      [点我收藏+]
 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

原文:https://www.cnblogs.com/lsc666js/p/13334702.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!