在线Python编辑器:编写、运行和分享你的Python代码
<!DOCTYPE html>
<html>
<head>
<title>在线Python编辑器 - 编写、运行和分享你的代码</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="container">
<h1>在线Python编辑器</h1>
<div class="editor">
<textarea id="code" placeholder="在这里编写Python代码"></textarea>
<button onclick="runCode()">运行</button>
</div>
<div id="output"></div>
</div>
<script src="script.js"></script>
</body>
</html>
<p>body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}</p>
<p>.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
text-align: center;
}</p>
<p>h1 {
color: #333;
}</p>
<p>.editor {
margin-bottom: 20px;
text-align: left;
}</p>
<p>textarea {
width: 100%;
height: 200px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
resize: none;
}</p>
<p>button {
background-color: #4CAF50;
color: white;
border: none;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin-top: 10px;
cursor: pointer;
}</p>
<p>#output {
background-color: #fff;
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
text-align: left;
}</p>
<p>function runCode() {
var code = document.getElementById('code').value;
var output = document.getElementById('output');
try {
output.innerHTML = eval(code);
} catch (error) {
output.innerHTML = '<span style="color: red;">' + error + '</span>';
}</p>
原文地址: https://www.cveoy.top/t/topic/pPBB 著作权归作者所有。请勿转载和采集!