number_arts = { 1: ''' _ / | | | | | |_| ''', 2: ''' ____ |___ \\ __) | / __/ |_____| ''', 3: ''' _____ |___ / |_ \\ ___) | |____/ ''', 4: ''' _ _ | || | | || |_ |__ _| |_| ''', 5: ''' ____ | ___| |___ \\ ___) | |____/ ''', 6: ''' __ / /_ | '_ \\ | (_) | \\___/ ''' } def get_random_number(min: int = 1, max: int = 6) -> int: import random return random.randint(min, max) def get_random_number_string(min_value: str = "1", max_value: str = "6") -> str: import random # 先判断二者是不是整数 if (float(min_value).is_integer() and float(max_value).is_integer() and "." not in min_value and "." not in max_value): return str(random.randint(int(float(min_value)), int(float(max_value)))) # 根据传入小数的位数,决定保留几位小数 if "." in str(min_value) or "." in str(max_value): decimal_places = max(len(str(min_value).split(".")[1]) if "." in str(min_value) else 0, len(str(max_value).split(".")[1]) if "." in str(max_value) else 0) return str(round(random.uniform(float(min_value), float(max_value)), decimal_places)) # 如果没有小数点,很可能二者都是指数表示或均为 inf,直接返回随机小数 return str(random.uniform(float(min_value), float(max_value))) def roll_number(wide: bool = False) -> str: raw = number_arts[get_random_number()] if wide: raw = (raw .replace("/", "/") .replace("\\", "\") .replace("_", "_") .replace("|", "|") .replace(" ", " ")) return raw