在线 Python 代码编辑器和共享平台 - 创建、运行和分享你的 Python 项目

欢迎来到在线 Python 网站

<h2>分享你的作品</h2>
<p>上传并与他人分享你的 Python 代码。</p>
<form action="upload.php" method="post">
    <label for="file">选择文件:</label>
    <input type="file" id="file" name="file"><br><br>
    <input type="submit" value="上传">
</form>

<h2>创建 Python 项目</h2>
<p>在线创建和运行 Python 项目。</p>
<textarea id="code" rows="10" cols="50"></textarea><br><br>
<button onclick="runCode()">运行</button>
<h3>输出:</h3>
<div id="output"></div>

<script src="https://cdn.jsdelivr.net/npm/python-programming-language@3.10.0-alpha1/standalone.js"></script>
<script>
    function runCode() {
        var code = document.getElementById("code").value;
        var output = document.getElementById("output");
        
        output.innerHTML = "";
        
        Sk.pre = "output";
        Sk.configure({output: function (text) {
            output.innerHTML += text;
        }});
        
        try {
            var module = Sk.importMainWithBody("<stdin>", false, code);
        } catch (e) {
            output.innerHTML += "<br>执行错误: " + e.toString();
        }
    }
</script>
在线 Python 代码编辑器和共享平台 - 创建、运行和分享你的 Python 项目

原文地址: https://www.cveoy.top/t/topic/pPz9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录