我现在在代码方面有点问题。我正在制作一个非常基本的RPG,遇到了这个问题: (未绑定方法)错误命令。错误) 我还运行python2.7.5和windows7。你知道吗
这是我的密码:
import os
class wrongCommand():
def wrong():
os.system("cls")
print "Sorry, the command that you entered is invalid."
print "Please try again."
def main():
print "Welcome to the game!"
print "What do you want to do?"
print "1.) Start game"
print "2.) More information/Credits"
print "3.) Exit the game"
mm = raw_input("> ")
if mm != "1" and mm != "2" and mm != "3":
print wrongCommand.wrong
main();
main()
所以首先,你要改变
至
(注:增加打开和关闭参数)
但是你会得到从
wrong
方法打印出来的行,以及该方法的返回值,目前没有。你知道吗所以我可能会改变
简单地
(注意:删除
print
语句)或者,您可以使用
wrong()
返回字符串,而不是打印一个字符串,然后使用此行那就好了。你知道吗
您要么调用类实例的
wrong()
方法,例如或者只是
无论哪种情况,您都必须将
wrong()
方法定义更改为否则会出现类似“wrong()只需要一个参数,却没有”这样的错误。你知道吗
也可以将错误的方法定义为类方法或静态方法:
或者
相关问题 更多 >
编程相关推荐