学习python第n天——我在看笨办法学python

代码块

#this is like your scripts with argv.
def print_two(*args):#def含义define(定义)
    arg1 , arg2 = args
    print(f"arg1:{arg1},arg2:{arg2}")

#ok,that *args is actually pointless,we can just do it
def print_two_argin(arg1,arg2):
    print(f"arg1:{arg1},arg2:{arg2}")

#this just takes one argument
def print_one(arg1):
    print(f"arg1:{arg1}")

#this one takes no arguments
def print_none():
    print("i got nothin'.")

print_two("zed","shaw")
print_two_argin("zed","shaw")
print_one("first!")
print_none()

运行结果

PS C:\Users\HH\lpthw> python ex9.py
arg1:zed,arg2:shaw
arg1:zed,arg2:shaw
arg1:first!
i got nothin'.
PS C:\Users\HH\lpthw>

 

posted on 2022-01-03 17:51  何奈时  阅读(27)  评论(0)    收藏  举报

导航