笨办法学python3练习代码ex18.py
Posted lscv26
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了笨办法学python3练习代码ex18.py相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章
笨办法学python3代码练习ex23.py 字符串字节串字符编码