python标准库介绍——35 pipes 模块详解

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python标准库介绍——35 pipes 模块详解相关的知识,希望对你有一定的参考价值。

==pipes 模块==


(只用于 Unix) ``pipes`` 模块提供了 
"转换管道 (conversion pipelines)" 的支持. 你可以创建包含许多外部工具调用的管道来处理多个文件. 
如 [Example 3-8 #eg-3-8] 所示.

====Example 3-8. 使用 pipes 模块====[eg-3-8]

```
File: pipes-example-1.py

import pipes

t = pipes.Template()

# create a pipeline
# 这里 " - " 代表从标准输入读入内容
t.append("sort", "--")
t.append("uniq", "--")

# filter some text
# 这里空字符串代表标准输出
t.copy("samples/sample.txt", "")

*B*Alan Jones (sensible party)
Kevin Phillips-Bong (slightly silly)
Tarquin Fin-tim-lin-bin-whin-bim-lin-bus-stop-F‘tang-F‘tang-Olé-Biscuitbarrel*b*
```

  

以上是关于python标准库介绍——35 pipes 模块详解的主要内容,如果未能解决你的问题,请参考以下文章

python 标准库subprocess

python:multiprocessing.Pipe和重定向标准输出

Python 开发神技 -- 使用管道 Pipe

python MultiProcessing标准库使用Queue通信的注意要点

python3.5学习第二章标准库,bytes

Python标准库:1. 介绍