<!DOCTYPE html>
<html>
<head>
<title>在线Python编辑器 - 免费在线编写和运行Python代码</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<h1>在线Python编辑器</h1>
</header>
<main>
<div class="editor">
<textarea id="code"></textarea>
<button onclick="runCode()">运行</button>
</div>
<div id="output"></div>
</main>
<footer>
<p>分享你的作品:<a href="https://github.com/yourusername/yourproject">https://github.com/yourusername/yourproject</a></p>
</footer>
<script src="script.js"></script>
</body>
</html>
<p>/* style.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}</p>
<p>header {
background-color: #333;
color: white;
padding: 20px;
}</p>
<p>h1 {
margin: 0;
}</p>
<p>main {
padding: 20px;
}</p>
<p>.editor {
margin-bottom: 20px;
}</p>
<p>textarea {
width: 100%;
height: 200px;
}</p>
<p>button {
padding: 10px;
}</p>
<p>#output {
border: 1px solid #333;
padding: 20px;
}</p>
<p>footer {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}</p>
<p>footer a {
color: white;
}</p>
<p>/* script.js */
function runCode() {
var code = document.getElementById(&quot;code&quot;).value;
var output = document.getElementById(&quot;output&quot;);</p>
<p>try {
var result = eval(code); // 注意:这种方式不够安全,请谨慎使用
output.innerHTML = result;
} catch (error) {
output.innerHTML = &quot;<span class='error'>&quot; + error + &quot;</span>&quot;;
}
}</p>
<img src="python_logo.png" alt="Python Logo">
在线Python编辑器:编写、运行、共享代码 - 免费在线使用

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

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