我有这些
def MsgBox1_YesChosen(sender,e):
if e.Key != "A": function0()
else:
function1()
function2()
function3()
def MsgBox1_NoChosen(sender,e):
if e.Key == "A": function0()
else:
function1()
function2()
function3()
Run Code Online (Sandbox Code Playgroud)
两个def可以合并在一起吗?它们之间的唯一区别是 "==" , "!="
def MsgBox1_WhatIsChosen(sender, e, yesOrNo):
if (e.Key != 'A') == yesOrNo:
function0()
else:
function1()
function2()
function3()
def MsgBox1_YesChosen(sender,e):
return MsgBox1_WhatIsChosen(sender, e, True)
def MsgBox1_NoChosen(sender,e):
return MsgBox1_WhatIsChosen(sender, e, False)
Run Code Online (Sandbox Code Playgroud)