小编use*_*002的帖子

Typeerror:object .__ new __()不带参数(帮助)

我只是想制作一个生成骰子的代码(在python中).这是代码:

import random

class Dice:
     def _init_(self, number_dice):
          self._dice = [6] * number_dice

     def roll_dice(self):
          for d in range(len(self._dice)):
               self._dice[d] = random.randit(1, 6)
          self._dice.sort()

     def print_roll(self):
          length = len(self._dice)
          print(str(lenth) + "dice:" + str(self._dice))



my_dice = Dice(2)
my_dice.roll_dice()
my_dice.print_roll()
Run Code Online (Sandbox Code Playgroud)

编译器对第18行说了些什么.我是编程的新手,所以任何事情都有帮助=]

python typeerror

4
推荐指数
2
解决办法
8645
查看次数

标签 统计

python ×1

typeerror ×1