我不知道如何让用户名存储整齐

I don't know how to make the user's name stored neatly

我想让游戏询问用户他的名字并整齐地存储。如果用户只是按下 Enter,那么游戏会说 Please enter a name。存储名称后,我需要放置一个表示用户名称的函数,这样我就可以在玩游戏时提及他的名字。

import random
import time
class Warrior:
    def Warrior(self, health, steel_armor, healing_potion, attack, rage):
        self.health = health
        self.steel_armor = steel_armor
        self.healing_potion = healing_potion
        self.attack = attack
        self.rage = rage
class Mage:
    def Mage(self, health_magic, magic_armor, magic_heal, magic_attack, mana):
        self.health = health_magic
        self.magic_armor = magic_armor
        self.magic_heal = magic_heal
        self.magic_attack = magic_attack
        self.mana = mana
class Archer:
    def Archer(self, health_spirit, elevens_armor, spiritual_heal, spiritual_attack, spirit):
        self.health = health_spirit
        self.elevens_armor = elevens_armor
        self.spiritual_heal = spiritual_heal
        self.spiritual_attack = spiritual_attack
        self.spirit = spirit
classes = ["Warrior", "Mage", "Archer"]
class Name:
    def Name(self, input):
        self.name = name 
        Name = input(print("Enter your name {} ").format(player_class) + "!")
name = ["Name"]

    run = True
main_menu = True
Play = input
Warrior = Warrior
Mage = Mage
Archer = Archer

while run:
    while main_menu:
        question = input("To play enter [Play]: ")
        if question != 'Play':
                print("Please enter a valid option")
                continue
        else:
            break
    print("you were a....."),
    print("Choose your class!")

    player_class = input(classes)
    while player_class not in classes:
        player_class = input(classes)
    print("Enter your name {}!".format(player_class))
    player_name = input(Name) #here is my problem
    print("Welcome to Glaux, {}!".format(player_name) + " you may choose a weapon to have.")

    print("")
    break

为什么 Name 是它自己的 class?

我会制作一个 class 播放器并制作 "name" 那个 class 的属性。

class Player:
    def __init__(self, name, class, ...):
        self.name = name
        self.class = class
        ...

那么你可以像这样提示一个名字: name = input("What's your name?: ")

然后根据提示信息制作播放器实例即可