Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23adccf

Browse files
committed
完善 sh 的描述和示例
1 parentc9ef0a0 commit23adccf

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

‎libs/python.wiki‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,29 @@ Home:[https://github.com/amoffat/sh]
355355

356356
这个项目可以用来取代标准库中的 subprocess;同时兼容 Python2 和 Python3。
357357

358-
代码示例
358+
使用它可以写出比 subprocess 更简洁、更优雅的代码。
359+
360+
代码示例——获取命令输出
359361
<source lang="python">
360362
from sh import ifconfig
361363
print(ifconfig("wlan0"))
362364
</source>
363365

366+
代码示例——命令行参数
367+
<source lang="python">
368+
from sh import curl
369+
&#35; 传统风格
370+
curl("https://program-think.blogspot.com/", "-o", "test.html", "--silent")
371+
&#35; 命名参数风格
372+
curl("https://program-think.blogspot.com/", o="test.html", silent=True)
373+
</source>
374+
375+
代码示例——管道
376+
<source lang="python">
377+
from sh import ls, wc
378+
print(wc(ls("/etc", "-1"), "-l"))
379+
</source>
380+
364381
== 3.4 本地进程间通信(IPC)==
365382

366383
<h4>mmap</h4>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp