推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
uti6770werty
V2EX  ›  Python

Win 下面持续跑 Python 程序,用什么 console-line 软件好?

  •  
  •   uti6770werty · Dec 2, 2019 · 4737 views
    This topic created in 2527 days ago, the information mentioned may be changed or developed.

    pycharm 的 console 输出似乎也回滚不了 8000 行以前的输出内容
    pycharm 一运行后,自身也挺占内存的
    不考虑 cmd.exe ,IDLE
    1、主要是想记录输出的内容。。。
    2、不考虑修改程序本身的 logging 完成输出内容。。。
    目前在用 PowerCMD,感觉一般般,就是上面提到的 console 输出记录不好用。。。

    18 replies  •  2019-12-13 18:07:07 +08:00
    charlie21
    charlie21
    Dec 2, 2019 via Android
    1
    python 1.py > output.txt
    zhzy
    zhzy
    Dec 2, 2019 via iPhone
    2
    不能重定向么
    senninha
    senninha
    Dec 2, 2019
    3
    git 自带的 mintty 环境运行 py,重定向到文件完事。
    wuwukai007
    wuwukai007
    Dec 2, 2019 via Android
    4
    pycharm 最离谱的是重启代码,控制台会清空
    Nasei
    Nasei
    Dec 2, 2019
    5
    重定向好像程序结束前是看不到结果的,你是持续运行的话,我觉得可以用 docker 的 windows container,有 python 的镜像,然后 docker log 看
    exip
    exip
    Dec 2, 2019 via Android
    6
    jupyter lab 或 notebook 几万行的输出都没问题
    lhx2008
    lhx2008
    Dec 2, 2019 via Android
    7
    不知道有没有像 linux 里面一个输出流变两个的,我觉得理论上应该有
    xml123
    xml123
    Dec 2, 2019
    8
    tee.exe ?
    Jirajine
    Jirajine
    Dec 2, 2019 via Android❤️1
    9
    @Nasei
    $python xx.py > log.log &
    $tail -f log.log
    lniwn
    lniwn
    Dec 2, 2019
    10
    cmder ?
    youngxhui
    youngxhui
    Dec 2, 2019
    11
    vscode + wsl + jupyter

    ![Snipaste_2019-12-02_22-45-47.png]( https://i.loli.net/2019/12/02/fTPzl79at5SxNuo.png)
    imycc
    imycc
    Dec 2, 2019
    12
    如果你装了 git bash 的话,

    # 将 test.py 的标准输出和错误全重定向到 test.log 中,并在后台执行
    python test.py > test.log 2>&1 &

    # 查看输出
    tail -f test.log

    不过要注意一个问题,如果你是用 print 打日志的话,tail -f 可能无法及时看到输出(在缓冲区里还没写进文件)
    BBCCBB
    BBCCBB
    Dec 2, 2019
    13
    python 自带的 logging 输出到文件也就几行代码得事情..
    crclz
    crclz
    Dec 2, 2019
    14
    docker
    levelworm
    levelworm
    Dec 3, 2019
    15
    直接用 log 库输出可行么?
    PolarBears
    PolarBears
    Dec 3, 2019
    16
    重定向输出到文本文件然后 Get-Content -Tail 0 -Wait file.log
    ClericPy
    ClericPy
    Dec 3, 2019
    17
    Windows 用服务跑不好么
    git-bash 基于 mintty 的, 兼容性比较好, 少数情况会遇到一些 win32 独有的兼容问题(比如 exe 程序), 这种时候我用的是 cmder
    如果你那边 logger 定的好, 这都不是问题
    如果 logger 不完整, 想重定向所有 stdout stderr, 除了用上面那个 git-bash 的 > 操作符, 可以考虑重绑定 sys.stdout sys.stderr 到你自己的类, 很多年以前我就这么干过

    https://paste.ubuntu.com/p/3mjY9q8Nvn/
    chaogg
    chaogg
    Dec 13, 2019
    18
    我直接用的 cmd.exe 也没问题,还能看输出
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   5008 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 384ms · UTC 09:18 · PVG 17:18 · LAX 01:18 · JFK 04:18
    ♥ Do have faith in what you're doing.