V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
aias
V2EX  ›  Python

fail 命令在 os.popen 中是不能执行的?

  •  1
     
  •   aias · May 17, 2016 · 2524 views
    This topic created in 3639 days ago, the information mentioned may be changed or developed.
    import os
    os.popen("tail -f /root/projects/***/***/logs/application.log")
    <open file 'tail -f /root/projects/***/***/logs/application.log', mode 'r' at 0x7f36bd7c9390>
    
    4 replies    2016-05-19 07:42:25 +08:00
    aias
        1
    aias  
    OP
       May 17, 2016
    os.popen("tail -f /root/projects/***/***/logs/application.log",“ r ”)直接没反应了..
    aias
        2
    aias  
    OP
       May 17, 2016
    还是不行..
    binux
        3
    binux  
       May 17, 2016
    In [1]: import os

    In [2]: f = os.popen("tail -f ./domains.txt")

    In [3]: f.readline()
    Out[3]: 'www.thephonebook.bt.com\n'

    In [4]: f.read(10)
    Out[4]: 'www.chambe'

    In [5]: f.readline()
    Out[5]: 'rofcommerce.com\n'
    aias
        4
    aias  
    OP
       May 19, 2016
    @binux 感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2502 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 15:12 · PVG 23:12 · LAX 08:12 · JFK 11:12
    ♥ Do have faith in what you're doing.