Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python模块没有属性_Python_Attributeerror - Fatal编程技术网

python模块没有属性

python模块没有属性,python,attributeerror,Python,Attributeerror,AttributeError:模块“actions”没有属性“MoveEast”在终端中不断弹出。我尝试过重命名函数并使用不同的导入方法,如 from actions import Actions 但什么也没发生 import items, enemies, dungeon, player, actions #rooms.py #function in question def adjacent_moves(self): moves = [] if dungeon.room_e

AttributeError:模块“actions”没有属性“MoveEast”在终端中不断弹出。我尝试过重命名函数并使用不同的导入方法,如

from actions import Actions
但什么也没发生

import items, enemies, dungeon, player, actions
#rooms.py
#function in question
def adjacent_moves(self):
    moves = []
    if dungeon.room_exists(self.x + 1, self.y):
        moves.append(actions.MoveEast())
    if dungeon.room_exists(self.x - 1, self.y):
        moves.append(actions.MoveWest())
    if dungeon.room_exists(self.x, self.y - 1):
        moves.append(actions.MoveNorth())
    if dungeon.room_exists(self.x, self.y + 1):
        moves.append(actions.MoveSouth())
    return moves

#actions.py
class Actions:
    def __init__(self, method, name, hotkey, **kwargs):
        self.method = method
        self.hotkey = hotkey
        self.name - name
        self.kwargs = kwargs

def MoveEast(Actions):
    def __init__(self):
        super().__init__(method=Player.move_right, name="Move Right", hotkey="r")

#from player.py
def move(self, dx, dy):
    self.location_x += dx
    self.location_y += dy
    print(dungeon.room_exists(self.location_x, self.location_y).intro_text())

def move_right(self):
    self.move(dx= 1, dy= 0)
改变

def MoveEast(Actions):
    def __init__(self):
        super().__init__(method=Player.move_right, name="Move Right", hotkey="r")

class MoveEast(Actions):
    def __init__(self):
        super().__init__(method=Player.move_right, name="Move Right", hotkey="r")