【发布时间】:2023-03-15 23:34:01
【问题描述】:
在.../CthuluPackage 在 CthuluCore.py 中,我有:
class Dice(object):
@staticmethod
def __RollSkillMenu():
bonus=int(input("Bonus>"))
penalty=int(input("Penalty>"))
return Dice.RollSkill(bonus-penalty)
在 CthuluSkills.py 中,我有
from CthuluPackage.CthuluCore import *
import inspect
class SkillCheckResult(object):
def __init__(self,targetSkill):
self.TargetSkill=targetSkill
print(Dice)
self.Roll=Dice.__RollSkillMenu()
当我尝试创建 SkillCheckResult 时,我收到消息:
AttributeError: type object 'Dice' has no attribute '_SkillCheckResult__RollSkillMenu'
这真的让我很困惑,因为据我所知,我并没有尝试调用任何名为 Dice 的东西。SkillCheckResult_RollSkillMenu,我只是想调用 Dice.RollSkillMenu。为什么 python 在我的方法调用前面加上这个?
【问题讨论】:
-
你真的写了
Dice.__RollSkillMenu()吗? -
我可能有,是的。我只是想找到一种方法来编辑这篇文章
标签: python-3.2