简体   繁体   English

我尝试使用 skulpt 制作 python 解释器,但遇到了意外错误。 我想在我的网站上使用它

[英]I tried to make a python interpreter using skulpt, but ran into an unexpected error. I want to use it on my website

So I am trying to do a python interpreter on my website using skulpt.所以我想在我的网站上使用 skulpt 做一个 python 解释器。 But im running to some issues and dont know how to fix them.但我遇到了一些问题,不知道如何解决它们。 The error will be probably in the js script which is shown below错误可能出现在如下所示的 js 脚本中

Error: Uncaught ReferenceError: Sk is not defined at runit (portfolio:33) at HTMLButtonElement.onclick (portfolio:57)错误: Uncaught ReferenceError: Sk is not defined at runit (portfolio:33) at HTMLButtonElement.onclick (portfolio:57)

HTML CODE: HTML 代码:

<html> 
<head> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript"></script> 
<script src="http://www.skulpt.org/js/skulpt.min.js" type="text/javascript"></script> 
<script src="http://www.skulpt.org/js/skulpt-stdlib.js" type="text/javascript"></script> 

</head> 

<body> 

<script type="text/javascript"> 

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}); 
   (Sk.TurtleGraphics || (Sk.TurtleGraphics = {})).target = 'mycanvas';
   var myPromise = Sk.misceval.asyncToPromise(function() {
       return Sk.importMainWithBody("<stdin>", false, prog, true);
   });
   myPromise.then(function(mod) {
       console.log('success');
   },
       function(err) {
       console.log(err.toString());
   });
} 
</script> 

<h3>Try This</h3> 
<form> 
<textarea id="yourcode" cols="40" rows="10">import turtle

t = turtle.Turtle()
t.forward(100)

print "Hello World" 
</textarea><br /> 
<button type="button" onclick="runit()">Run</button> 
</form> 
<pre id="output" ></pre> 
<!-- If you want turtle graphics include a canvas -->
<div id="mycanvas"></div> 

</body> 

</html> 

I ran out of ideas how to fix this.我没有办法解决这个问题。 Here is the documentation > https://skulpt.org/using.html这是文档> https://skulpt.org/using.html

Just remove www.只需删除www. from script urls.来自脚本网址。

You should use http://skulpt.org/js/skulpt.min.js instead of http://www.skulpt.org/js/skulpt.min.js您应该使用http://skulpt.org/js/skulpt.min.js而不是http://www.skulpt.org/js/skulpt.min.js

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 浏览器中的 Python 解释器。 在 Skulpt 中使用外部模块 - Python interpreter in browser. Using external modules in Skulpt 我想让我的盒子偏移,我尝试放置属性但没有任何反应。 我使用 Tailwind 和 React - I want to make my box offset, I tried putting the property but nothing happens. I use Tailwind & React 尝试对 Web 表单方法进行 Ajax 调用并收到内部服务器错误。 我已经尝试了几乎所有类似问题的解决方案 - Trying to make an Ajax call to a web form method and getting an internal server error. I have tried almost all solutions to similar questions 如何将模块添加到我的Skulpt页面? - How do I add modules to my Skulpt page? 我目前正在学习反应,我遇到了错误。 TypeError:无法读取未定义的属性“图像” - I am currently learning react and I ran into error. TypeError: Cannot read property 'image' of undefined 我无法显示我网站的页面,我尝试调试未捕获的语法错误 1: import { useState } from 'react' - I cannot display a page of my website, i tried debugging Uncaught Syntax Error 1: import { useState } from 'react' 我有一个意外的令牌错误。 它来自哪里? - I have an unexpected token error. Where is it coming from? 我想使用Jquery在我的网站中嵌入API调用 - I want to Embed an API call in my Website using Jquery 我想使用 Meshphongmaterial 在我的网站上添加自定义地面材料 - I want to add custom ground material on my website using Meshphongmaterial Selenium Python执行JavaScript单击链接,我得到一个错误。 我认为我的语法是错误的 - Selenium Python Execute JavaScript click link i get an error. I think my syntax is wrong
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM