V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2011-12-10 22:19:33 +08:00 · 10673 次点击
    这是一个创建于 4520 天前的主题,其中的信息可能已经有所发展或是发生改变。
    google出来的不是我要的答案。谢谢。

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

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

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

    是用空上重定向的。。。 aa.py<file.txt
    kojp
        3
    kojp  
    OP
       2011-12-10 22:22:58 +08:00
    @bhuztez

    对,这样也行。我一就是有你这么一个念头划过的想的。。。但觉得太天真了,懒,没有试一下。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4714 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 04:02 · PVG 12:02 · LAX 21:02 · JFK 00:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.