python 如何获得重定向输入
发布时间:2021-05-20 编辑:jiaochengji.com
教程集为您提供python 如何获得重定向输入等资源,欢迎您收藏本站,我们将为您提供最新的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的sys有哪些功能
Python input()函数:获取用户输入的字符串
linux如何打开python
python中sys是什么模块
linux中如何使用python
shell 输出重定向用法浅析(图文)
python难还是ruby难
python做后端好吗
上一篇:python中单引号和双引号的区别
下一篇:python如何输入多行
[关闭]