3

Pythonの問題を理解できません。私はそのようなコードを持っています:

class Rain:
    def __init__(self):
       self.x = random.randint(0, Core.Utils.ScreenResolutionX)
       print type(Core.Utils.ScreenResolutionX) # prints int
       print Core.Utils.ScreenResolutionX # print 1152

エラー:

    self.x = random.randint(0, Core.Utils.ScreenResolutionX)
  File "/usr/lib/python2.7/random.py", line 241, in randint
    return self.randrange(a, b+1)
  File "/usr/lib/python2.7/random.py", line 213, in randrange
    if width >= maxwidth:
AttributeError: 'Rain' object has no attribute 'getType'
4

1 に答える 1

1

NULLメソッドの1つで誤ってPythonに返されています。例外を発生させる必要がない場合は、必ずincrefを実行してPythonに戻ってくださいPyNone

于 2011-04-12T18:51:21.917 に答える