【问题标题】:calling a function placed in another调用放置在另一个中的函数
【发布时间】:2020-09-26 07:01:17
【问题描述】:

我在调用放置在另一个中的函数时遇到问题。 我必须从 [Display_Recette (Name_HV)] 调用 [selectItem (frame)]

def SAF_Contenu(root):
     def selectItem(frame):   
def Display_Recette(Name_HV):
     F_TOP_Treeview_ID.bind('<<Declenche>>', selectItem(iid))

【问题讨论】:

  • 假设 selectItem() 有一个返回值,您可以缩进 Display_Recette() 成为一个内部函数并以这种方式调用它。
  • 您要做的是通过外部方法(Display_Recette())调用私有方法(selectItem(),只有其父 SAF_Contenu() 可以调用)。

标签: python jquery css forms menu


【解决方案1】:

你可以制作内部函数global

def fnA(a,b):
    global fnB
    def fnB(c,d):
        return c+d
    return a*b
print(fnA(1,2))
print(fnB(1,2))
2
3

【讨论】:

    猜你喜欢
    • 2023-03-12
    • 2016-10-28
    • 1970-01-01
    • 1970-01-01
    • 2017-03-07
    • 2019-09-17
    • 2013-12-17
    • 1970-01-01
    • 2022-01-20
    相关资源
    最近更新 更多