python 如何获得重定向输入
通过内置的fileinput模块即可实现,创建文件filein.py:
#!/usr/bin/env python import fileinput f_input = fileinput.input() for line in f_input: print(line, end='')
相关推荐:《Python教程》
增加可执行权限:
chmod a x filein.py
使用:
$ ls | ./filein.py # Prints a directory listing to stdout. $ ./filein.py /etc/passwd # Reads /etc/passwd to stdout. $ ./filein.py < /etc/passwd # Reads /etc/passwd to stdout.
您可能感兴趣的文章:
python 如何获得重定向输入
Python 简介
python为何如此流行
Python的sys有哪些功能
python中sys是什么模块
python如何模拟登录Github
linux如何打开python
linux中如何使用python
python做后端好吗
python难还是ruby难