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*
```

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM