我想通过JavaScript文件执行Python脚本,因为我想将Python脚本的结果打印到html页面。我首先研究了python-shell
模块。我遵循了以下教程:
我成功地遵循了教程,一切正常。你知道吗
不过,我现在想在控制台中延迟打印一些数字。我的Python脚本包含以下代码:
while True:
print(random.randint(1,101))
time.sleep(10)
当我运行JavaScript代码时,什么也没发生。我做了一些调试,删除了time.sleep()
语句,它就工作了。你知道吗
正确的方法是什么?当我删除time.sleep()
时,为什么这会起作用?你知道吗
打印之后,需要刷新python脚本中的标准输出流。你知道吗
相关问题 更多 >
编程相关推荐