提问人:meko 提问时间:10/29/2023 更新时间:10/29/2023 访问量:40
如何在 Jupyter 中使用 int(input())
How to use int(input()) in Jupyter
问:
我尝试在Jupyter中运行以下代码:
term_no = input('Enter number of approximations to use: ')
term_no = int(term_no)
print(term_no)
并返回错误TypeError: int() argument must be a string, a bytes-like object or a real number, not 'PyodideFuture'
当我在 VS Code 中运行它时,没有错误。Jupyter 是否存在错误,或者我应该添加一些额外的内容?
答:
-1赞
MrTraitor
10/29/2023
#1
评论
0赞
Community
10/29/2023
正如目前所写的那样,你的答案尚不清楚。请编辑以添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。您可以在帮助中心找到有关如何写出好答案的更多信息。
1赞
Wayne
10/29/2023
不,在 ALL Jupyter 中工作的情况并非如此。它目前在 JupyterLite 中不起作用,这就是 OP 发布的内容。然而,OP并没有在帖子中包括这个重要的观点,只有从错误中提到的“Pyodide”中才能明显看出,如果人们知道这意味着什么的话。我从您的屏幕截图中可以看出,您正在使用典型的、功能齐全的 Python 3 ipykernel。该命令在那里起作用,因为如果您查看 Matthias 链接的内容,您就会看到。目前,它不适用于基于 Web 程序集 (WASM) 的 Python 内核 (Pyodide)。
评论