import subprocess import sys class MaichartConverterFailed(BaseException): def __str__(self): return "Maichart conversion failed." def ma2tosimai(ma2path): cmd = [ "mcc/MaichartConverter","CompileMa2","-p", ma2path, "-f","SimaiFes" ] result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) text = result.stdout start_index = text.find("TargetFormat : SimaiFes") # 如果找到了该字符串,提取后面的内容 if start_index != -1: extracted_content = text[start_index + len("TargetFormat : SimaiFes"):].strip() else: extracted_content = "" raise MaichartConverterFailed(result.stderr) return extracted_content if __name__ == "__main__": print(ma2tosimai(""))