当我在两个级别的函数中调用函数时,会出现以下错误:“名称错误:未定义名称‘destinateries’”:
即使我在函数中将其声明为全局变量,也会出现错误:
def PostToFaceBookWall(msg):
global destinataires
try:
....
except Exception as e:
subject = 'xxxxxxxxxxx'
error = str(e)
SendMail(destinataires,subject,error)
def get_prices_for_next_days():
....
subject = "xxxxx")
html = "xxxxxx"
SendMail(destinataires,subject,html) # NO PROBLEM WITH THIS INSTRUCTION : I GET MAIL
PostToFaceBookWall(Msg2FB) # PROBLEM WITH THIS INSTRUCTION : I GET ERROR
def SendMail(dest,sujet, msg):
"""Send a mail"""
if __name__ == '__main__':
destinataires = ['xxxxx@xxxx.xxx'] #a global variable
get_prices_for_next_days()
级别包含功能是否有限? 函数中定义的全局变量在调用的子函数中是未知的
我认为您必须通过destinataries才能获取下一天的价格()函数
如果没有传出,您无法访问get_price_for_next_day()函数中的目的地
相关问题 更多 >
编程相关推荐