小编Tar*_*ant的帖子

TypeError:object .__ new __()不带参数

我一直在研究Python The Hard Way并且我得到了上述错误,并且不知道为什么.我拿出了大部分我认为可能的填充文字.对不起,如果有点长.

from sys import exit
from random import randint

class Game(object):

    def __int__(self, start):
        self.quips = [
             "You died. You kinda suck at this.",
             "Your mom would be proud. If shw were smarter.",
             "Suck a loser.",
             "I have a small puppy that's better at this."
        ]
        self.start = start

    def play(self):
        next_room_name = self.start

        while True:
            print "\n-------"
            room = getattr(self, next_room_name)
            next_room_name = room()

    def death(self):
            print self.quips[randint(0, len(self.quips)-1)]
            exit(1)

    def central_corridor(self):
        print "The Gothons of …
Run Code Online (Sandbox Code Playgroud)

python

11
推荐指数
1
解决办法
1万
查看次数

Java编译器错误消息"<identifier> expected"是什么意思?

class if{
    public static void main (String args[]){
        int x = 9;
        if (x <= 9){
            System.out.println("Yay");
        }else{
            System.out.println("Yay");
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

我正在使用Notepad ++作为文本编辑器从编译器运行它.我在编译器中遇到错误<identifier> expected class if.另一个错误说illegal start of expression.还有说error ";" expected.我总共有9个错误.

我确保匹配所有{}().甚至刮掉了程序并再次尝试相同的结果.

java compiler-errors

5
推荐指数
1
解决办法
3万
查看次数

从一个单词中获取一封信

a = ['cat','dog']

random.choice(a)
Run Code Online (Sandbox Code Playgroud)

我怎样才能选择一个随机单词并拔出一个字母?我已经搜索和试验了诸如此类但无法找到答案的内容.谢谢.

我不想要一个随机的字母,例如我希望它选择一个单词,cat.然后我希望有人猜猜ca或t.有点像刽子手

python

0
推荐指数
2
解决办法
2493
查看次数

标签 统计

python ×2

compiler-errors ×1

java ×1