如何解决从 Ace Editor 获得的代码值的 Brython Giving 错误

How to Solve Brython Giving Error for the code value it got from Ace Editor

请检查我的问题的图片或图片链接!

When I write my code in Ace Editor like this then Brython gives the correct result!

When I extend my code or the div resizes and hides the code like in this case 'pri' of print is hidden because of extending code, it gives an error

I have also tried wrapping the text but then also Brython gives an error!

我的Brython和Ace配置如下!

function run() {
  const console = document.getElementById("console");
  const runner = new BrythonRunner({
    stdout: {
      write(content) {
        console.innerHTML += content;
        console.scrollTop = console.scrollHeight;
      },
      flush() {}
    },
    stderr: {
      write(content) {
        console.innerHTML += content;
        console.scrollTop = console.scrollHeight;
      },
      flush() {}
    },
    stdin: {
      async readline() {
        console.innerHTML += "\n";
        console.scrollTop = console.scrollHeight;
        var userInput = prompt();
        return userInput;
      },
      flush() {}
    }
  });
  var code = editor.getValue();
  runner.runCode(code)
}

function run_init() {

  if (document.getElementById("console") != '') {
    document.getElementById("console").innerHTML = '';
    run();
    console.log(document.getElementById('editor').innerText);


  } else {
    run()
  }
}
<button onclick="run()">run</button>
<div class='editor_class' id='editor'>print('Hello World')</div>
<div class='compiler_class'><textarea id='console' readonly></textarea></div>

<script src="https://ajaxorg.github.io/ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="https://raw.githack.com/pythonpad/brython-runner/master/lib/brython-runner.bundle.js" type="text/javascript" charset="utf-8"></script>

<script>
  var editor = ace.edit("editor");
  editor.setTheme("ace/theme/vibrant_ink");
  editor.getSession().setMode("ace/mode/python");
  editor.setFontSize("16px");
  editor.container.style.height = "100px"
  editor.setOptions({
    enableLiveAutocompletion: true,
    copyWithEmptySelection: true,
    showGutter: true,

    useWrapMode: false, // wrap text to view
    indentedSoftWrap: false,
  });
</script>

您的错误是在编辑器容器上使用了 innerText 而不是 editor.getValue();,我已经更新了您的代码片段,现在可以使用了。