我试图通过询问用户的输入来调用我的方法,并使用输入来调用方法。我认为我最好的尝试看起来像这样:
class Possibilities:
def change_password(self):
do_change_password()
def do_change_password():
<some code here>
call = input('what do you want to do?')
Possibilities.call() #here the error happens
有没有解决方案?
答案 0 :(得分:0)
如果您真的想要遵循此方法,则应考虑使用public class ProductsModel {
@SerializedName("result")
@Expose
private ResultProducts result;
public ResultProducts getResult() {
return result;
}
public void setResult(ResultProducts result) {
this.result = result;
}
}
。 classmethod
是一个变量,您应该将call
方法作为参数传递给它。
例如:
Possibilities
修改强>
你也可以忘记课程并选择地图制作者,如:
def do_change_password():
<some code here>
class Possibilitiees:
@classmethod
def choose_action(cls, action):
if action == "change password":
do_change_password()
call = input("what do you want to do?")
Possibilities.choose_action(call)