class conf: @staticmethod def to_int(value: str, params, separator: str = '_'): return int(value) @staticmethod def to_float(value: str, params, separator: str = '_'): return float(value) @staticmethod def to_str(value: str, params, separator: str = '_'): return str(value) @staticmethod def to_bool(value: str, params, separator: str = '_'): return bool(value) @staticmethod def to_list(value: str, params, separator: str = '_'): params_list = params.split(separator, -1) return value.split(params_list) @staticmethod def config_type(value: str): data = { "int": conf.to_int, "float": conf.to_float, "str": conf.to_str, "bool": conf.to_bool, "list": conf.to_list, } return data[value] ddd = conf.config_type() func = ddd["int"] print(func("123")) # 输出: 123