gpt4 book ai didi

python - 在 vs code python 调试控制台中运行循环/多行

转载 作者:行者123 更新时间:2023-12-05 00:55:00 25 4
gpt4 key购买 nike

如何在 VS Code 的 python 调试控制台中运行一个简单的循环?当我尝试输入以下内容时:

for el in dataset:

它给了我下面的错误。我似乎可以输入变量名,但不能像在普通 python REPL 中那样输入多行命令。

Traceback (most recent call last):
File "/home/tensorflow/.local/lib/python3.6/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 416, in evaluate_expression
compiled = compile(_expression_to_evaluate(expression), '<string>', 'eval')
File "<string>", line 1
for el in dataset:
^
SyntaxError: invalid syntax

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/tensorflow/.local/lib/python3.6/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 969, in internal_evaluate_expression_json
pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=True)
File "/home/tensorflow/.local/lib/python3.6/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 368, in new_func
return _run_with_unblock_threads(original_func, py_db, curr_thread, frame, expression, is_exec)
File "/home/tensorflow/.local/lib/python3.6/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 336, in _run_with_unblock_threads
return _run_with_interrupt_thread(original_func, py_db, curr_thread, frame, expression, is_exec)
File "/home/tensorflow/.local/lib/python3.6/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 307, in _run_with_interrupt_thread
return original_func(py_db, frame, expression, is_exec)
File "/home/tensorflow/.local/lib/python3.6/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_vars.py", line 418, in evaluate_expression
Exec(_expression_to_evaluate(expression), updated_globals, frame.f_locals)
File "/home/tensorflow/.local/lib/python3.6/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "<string>", line 1
for el in dataset:
^
SyntaxError: unexpected EOF while parsing

最佳答案

你有两个选择:

  1. 在新的编辑器窗口中编写命令,然后只需将代码复制并粘贴到调试控制台中,然后按 Enter
  2. 直接在调试控制台中编写命令。如果要输入新行,请按 Shift+Enter。命令完成后,使用 Enter
  3. 执行

关于python - 在 vs code python 调试控制台中运行循环/多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65588130/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com