当前位置: 首页 > 工具软件 > Skulpt > 使用案例 >

python在线工具-Skulpt在线模拟运行Python工具

贲文景
2023-12-01

function outf(text) {

var mypre = document.getElementById("output");

mypre.innerHTML = mypre.innerHTML + text;

}

function builtinRead(x) {

if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined)

throw "File not found: '" + x + "'";

return Sk.builtinFiles["files"][x];

}

function runit() {

var prog = document.getElementById("yourcode").value;

var mypre = document.getElementById("output");

mypre.innerHTML = '';

Sk.pre = "output";

Sk.configure({ output: outf, read: builtinRead, __future__: Sk.python3});

(Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'mycanvas';

var myPromise = Sk.misceval.asyncToPromise(function() {

return Sk.importMainWithBody("", false, prog, true);

});

myPromise.then(function(mod) {

console.log('success');

},

function(err) {

console.log(err.toString());

});

}

Try This

import turtle

print('hello')

t = turtle.Turtle()

t.color('red')

t.forward(75)


Run

 

 类似资料: