V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
conghuiwang
V2EX  ›  Visual Studio Code

不懂就问, VS CODE 单文件 Python 调试

  •  
  •   conghuiwang · 2020-06-19 21:00:45 +08:00 · 1337 次点击
    这是一个创建于 1377 天前的主题,其中的信息可能已经有所发展或是发生改变。
    新建一个 py 文件,输入如下代码:

    print("hello,world")

    右键 Run Current Test File 点击无反应,无输出。
    右键 Run Python File in Terminal 点击运行,有输出。

    那么问题来了,Run Current Test File 到底是做什么的?
    CNife
        1
    CNife  
       2020-06-20 09:23:21 +08:00
    https://code.visualstudio.com/docs/python/testing#_run-tests

    Run Current Test File 是 Runs the test in the file that's currently viewed in the editor.

    这个功能是用来适配 unittest 、pytest 、nose 这些测试框架的,你这个文件不是 Test File,自然没反应。

    想调试,打好断点,按 F5,选择 Python File 即可。
    conghuiwang
        2
    conghuiwang  
    OP
       2020-06-20 21:01:15 +08:00
    Thanks.
    这个菜单项,好奇怪。
    conghuiwang
        3
    conghuiwang  
    OP
       2020-06-20 21:01:30 +08:00
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3304 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:28 · PVG 19:28 · LAX 04:28 · JFK 07:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.