[英]How to set up the Google Code Jam interactive judge for a C++ solution on Windows?
[英]How to debug Google Code Jam interactive problems on VSCode using python?
我嘗試下載示例交互式問題數字猜測問題。 他們在描述選項卡中提供local testing tool
,在分析選項卡中提供 python 解決方案,同時運行兩個腳本的interactive_runner.py 。
將解決方案保存在solution.py
后,我可以在 shell 上成功運行: python3 interactive_runner.py python3 local_testing_tool.py 0 -- python3 solution.py
。
問題是我無法使用 VSCode 調試它。 我嘗試將所有 3 個文件放在一個文件夾中並使用以下啟動。json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Arquivo Atual",
"type": "python",
"request": "launch",
"program": "interactive_runner.py python3 local_testing_tool.py 0 -- python3 ${file}",
"console": "integratedTerminal",
}
]
}
當我使用調試器運行solutions.py 時,出現錯誤:
env DEBUGPY_LAUNCHER_PORT=40453 /home/user/.pyenv/versions/3.8.2/bin/python3.8 /home/user/.vscode/extensions/ms-python.python-2020.4.74986/pythonFiles/lib/python/debugpy/no_wheels/debugpy/launcher "interactive_runner.py python3 local_testing_tool.py 0 -- python3 /home/user/workspace/wargames/GoogleCodeJam/2018/PracticeSession/NumberGuessing/solution.py"
Traceback (most recent call last):
File "/home/user/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/user/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/user/.vscode/extensions/ms-python.python-2020.4.74986/pythonFiles/lib/python/debugpy/no_wheels/debugpy/__main__.py", line 45, in <module>
cli.main()
File "/home/user/.vscode/extensions/ms-python.python-2020.4.74986/pythonFiles/lib/python/debugpy/no_wheels/debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/home/user/.vscode/extensions/ms-python.python-2020.4.74986/pythonFiles/lib/python/debugpy/no_wheels/debugpy/../debugpy/server/cli.py", line 267, in run_file
runpy.run_path(options.target, run_name=compat.force_str("__main__"))
File "/home/user/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 262, in run_path
code, fname = _get_code_from_file(run_name, path_name)
File "/home/user/.pyenv/versions/3.8.2/lib/python3.8/runpy.py", line 232, in _get_code_from_file
with io.open_code(fname) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'interactive_runner.py python3 local_testing_tool.py 0 -- python3 /home/user/workspace/wargames/GoogleCodeJam/2018/PracticeSession/NumberGuessing/solution.py'
關於如何做到這一點有更好的方法嗎?
"program"
參數只需要文件的路徑,因此會出現“沒有這樣的文件或目錄”的錯誤。 您要做的是獲取執行行的 rest 並將它們設為 arguments:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Arquivo Atual",
"type": "python",
"request": "launch",
"program": "interactive_runner.py",
"console": "integratedTerminal",
"args": ["python3", "local_testing_tool.py", "0", "--", "python3", "${file}"] // Not sure if `${file}` will work here.
}
]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.