V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
BBrother
V2EX  ›  问与答

问个关于 vscode 的问题

  •  
  •   BBrother · 2016-11-28 12:31:07 +08:00 · 1932 次点击
    这是一个创建于 2705 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我用 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 条回复    2016-11-29 08:42:35 +08:00
    eric6356
        1
    eric6356  
       2016-11-28 14:23:39 +08:00
    你需要 Python extension ,然后可以有很完善的 debug 支持
    BBrother
        2
    BBrother  
    OP
       2016-11-28 14:28:01 +08:00
    @eric6356 有这个,问题还存在,而且我说的问题跟 debug 没什么关系。
    vghdjgh
        3
    vghdjgh  
       2016-11-28 15:06:44 +08:00
    去插件仓库里开 issue
    eric6356
        4
    eric6356  
       2016-11-28 15:07:35 +08:00   ❤️ 1
    debug 不是可以直接实时在 debug console 里输出的么。这样既可以实时,又没有 cmd 的中文编码问题。
    Kisesy
        5
    Kisesy  
       2016-11-28 15:14:17 +08:00
    给 python 加参数 -u 这样就会即时输出了
    realityone
        6
    realityone  
       2016-11-28 15:18:09 +08:00   ❤️ 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  
       2016-11-28 15:18:59 +08:00
    加上

    "PYTHONUNBUFFERED": "0"
    BBrother
        8
    BBrother  
    OP
       2016-11-28 15:30:01 +08:00
    @eric6356
    @realityone

    感谢!
    realityone
        9
    realityone  
       2016-11-28 16:39:30 +08:00 via iPhone
    (/ω\)
    贴错了,应该是等于 1 才对
    BBrother
        10
    BBrother  
    OP
       2016-11-29 08:42:35 +08:00
    @realityone 好像都可以啊
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3140 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 14:43 · PVG 22:43 · LAX 07:43 · JFK 10:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.