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在您的一种方法中错误地返回到 Python。如果不需要引发异常,请始终确保增加并返回Python。PyNone

于 2011-04-12T18:51:21.917 回答