BBrother
V2EX  ›  问与答

问个关于 vscode 的问题

  •  
  •   BBrother · Nov 28, 2016 · 2450 views
    This topic created in 3462 days ago, the information mentioned may be changed or developed.

    我用 vscode 写 python ,系统是 win10 ,用 ctrl+shift+b 运行的话,会等整个进程结束再输出结果,如果 run in terminal 的话又会有中文编码的问题,大家怎么解决的?

    import time
    print('begin')
    time.sleep(10)
    print('end')
    

    比如上边, ctrl+shift+b 会等 10 秒之后输出 'begin' 和 'end', run in terminal 是先 'begin' 然后等 10 秒然后 'end'。

    10 replies    2016-11-29 08:42:35 +08:00
    eric6356
        1
    eric6356  
       Nov 28, 2016
    你需要 Python extension ,然后可以有很完善的 debug 支持
    BBrother
        2
    BBrother  
    OP
       Nov 28, 2016
    @eric6356 有这个,问题还存在,而且我说的问题跟 debug 没什么关系。
    vghdjgh
        3
    vghdjgh  
       Nov 28, 2016
    去插件仓库里开 issue
    eric6356
        4
    eric6356  
       Nov 28, 2016   ❤️ 1
    debug 不是可以直接实时在 debug console 里输出的么。这样既可以实时,又没有 cmd 的中文编码问题。
    Kisesy
        5
    Kisesy  
       Nov 28, 2016
    给 python 加参数 -u 这样就会即时输出了
    realityone
        6
    realityone  
       Nov 28, 2016   ❤️ 1
    {
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "0.1.0",
    "command": "python",
    "isShellCommand": true,
    "options": {
    "env": {
    "PYTHONUNBUFFERED": "0"
    }
    },
    "args": [
    "main.py"
    ],
    "showOutput": "always"
    }
    realityone
        7
    realityone  
       Nov 28, 2016
    加上

    "PYTHONUNBUFFERED": "0"
    BBrother
        8
    BBrother  
    OP
       Nov 28, 2016
    @eric6356
    @realityone

    感谢!
    realityone
        9
    realityone  
       Nov 28, 2016 via iPhone
    (/ω\)
    贴错了,应该是等于 1 才对
    BBrother
        10
    BBrother  
    OP
       Nov 29, 2016
    @realityone 好像都可以啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1127 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 66ms · UTC 18:20 · PVG 02:20 · LAX 11:20 · JFK 14:20
    ♥ Do have faith in what you're doing.