# default parameter: Must be placed at the end of the formal parameter list
# def send (name,xx = "OK"):
# ...
# # using default parameters
# Send ("Eric") #对形式参数的第一个元素赋值, the second element uses the default parameters.
# # Specify Parameters
# Send ("Eric", "No") #对形式参数的第一个元素赋值, the default parameter of the second element is re-assigned.
#
# def send (mail_addr,xx = "OK", content,): #xx = "OK" in the middle will be an error
def send (mail_addr,content,xx ="OK"):#默认参数需要放到参数列表最后, xx = "OK" is re-assigned when the function is called.
Print (MAIL_ADDR,CONTENT,XX)
# print ("Send mail success:", Mail_addr,content)
Return True
While True:
EM =Input"Please enter your email address:")
# result = Send (EM) #TypeError: Send () Missing 1 required positional argument: ' Content '
#报错, the actual parameter is passed 1, the formal parameter is 2.
result = Send (em,"Good luck","no") #em是参数传递的内容, can be multiple, default is one by one corresponding
#
if result = = True:
Print ("Send Success")
Else:
Print ("Send Failed")
Python Road "third": Python Basics (14)--Function default parameters