jupyter笔记本没有执行代码

2024-04-28 08:55:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近开始学习python,到目前为止没有问题。昨天,jupyter笔记本停止执行代码。我在网上搜索过,重新启动了内核,重新启动了我的windows机器,并试图找到一种方法来理解它在做什么,这样我就可以继续了,但是我没有找到解决方案,也没有找到我的代码不再被执行的原因。我在windows机器上运行代码,在windows上运行chrome。我没有在我的机器上安装jupyter。我在azure网络上运行它。在

请帮忙。在

谢谢, 大卫


Tags: 方法代码网络机器windows笔记本jupyter原因
3条回答

程序仍然处于“代码”模式。告诉我们通过ctrl+执行。在过去的三个星期里,我一直没有问题。在

我想我明白了。如果你这样写,那么你可以第一次运行它。但从第二次开始就不会执行了。因为jupyter只清除代码块输出,而不释放while循环。在

while True:
    a = input("Input a number: ")
    if a.isdigit():
        string_container += a + "\n"
        add_container += int(a)
    else:
        if a == 'A':
            print(Add_container)
        else:
            if a == 'T':
                print(string_container)
            else:

                if a=="q":
                    os._exit(0)
                else:

                    print("invalid input")

你应该把你的代码放在一个try-catch块中,就像这样。在

^{pr2}$

所以你必须

1. Select restart the kernel and clear output
2. Add try-catch so you can use "kernel interrupt" to kill the while loop
3. Whenever you finish using this while loop, select "kernel" -> "interrupt" to kill it completely

希望有帮助

                                                                                                         import os

字符串容器=“” 添加容器=0 定义添加报告(整数加载):

总计=0

总计=总计+整数负载

#添加容器=0

^{pr2}$

相关问题 更多 >