【发布时间】:2010-10-27 03:09:28
【问题描述】:
我正在尝试使用 IronPython in the browser 并尝试导入外部 python 脚本:
<script src="http://gestalt.ironpython.net/dlr-latest.js" type="text/javascript">
</script>
...
<script type="application/python" src="test.py" defer="true"></script>
<script type="application/python">
import test
test.Hello()
</script>
import 语句似乎运行成功(如果 test.py 不存在,它将失败)。但是,它似乎没有加载文件的内容。 test.py 包含以下代码:
document.testing1.innerHTML = 'Hello from test.py'
def Hello():
window.Alert('Hello from test.py')
事实上,test.py 中的内容似乎没有任何区别。它不会抱怨语法错误。
在您可以从浏览器中访问的 IronPython 控制台中,会发生同样的问题:
>>> import test
>>> dir(test)
['__builtins__', '__doc__', '__file__', '__name__', '__package__']
>>> test.Hello()
Traceback (most recent call last):
at <module> in <string>, line 1
at <module> in <string>, line 0
AttributeError: 'module' object has no attribute 'Hello'
我做错了什么?
更新:它可以与新的 IronPython 2.7 beta 1 VS2010 集成一起使用,该集成启动了“Chiron”测试网络服务器,但在我使用 WebMatrix 时不行。我想知道 WebMatrix 上为 .py 文件配置的 mime 类型是否有问题?
【问题讨论】:
标签: silverlight ironpython dynamic-language-runtime