推荐学习书目
› 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
kojp
V2EX  ›  Python

谁能解释一下sys.stdin的用法?或者给个链接。

  •  
  •   kojp · Dec 10, 2011 · 11789 views
    This topic created in 5406 days ago, the information mentioned may be changed or developed.
    google出来的不是我要的答案。谢谢。

    有一段程序
    msg=email.message_from_file(sys.stdin)

    我输入了文件名后,没有任何动作,也不报错。
    3 replies  •  1970-01-01 08:00:00 +08:00
    bhuztez
        1
    bhuztez  
       Dec 10, 2011
    直接 cat filename | python your-script.py
    kojp
        2
    kojp  
    OP
       Dec 10, 2011
    呃。。会了。。。

    不是带参数,也不是输入文件名。

    是用空上重定向的。。。 aa.py<file.txt
    kojp
        3
    kojp  
    OP
       Dec 10, 2011
    @bhuztez

    对,这样也行。我一就是有你这么一个念头划过的想的。。。但觉得太天真了,懒,没有试一下。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   875 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 21:49 · PVG 05:49 · LAX 14:49 · JFK 17:49
    ♥ Do have faith in what you're doing.