如何传递Python';s帮助(';模块';)在一行中输出到pbcopy?
就像标题地址一样,如何做到这一点?我愚蠢地尝试了以下几点,但我将在这里分享我的愚蠢,这样你就可以知道我想要发生什么:如何传递Python';s帮助(';模块';)在一行中输出到pbcopy?,python,macos,unix,terminal,copy-paste,Python,Macos,Unix,Terminal,Copy Paste,就像标题地址一样,如何做到这一点?我愚蠢地尝试了以下几点,但我将在这里分享我的愚蠢,这样你就可以知道我想要发生什么: myelf$python帮助('modules')| pbcopy 这是个好主意吗 fout = open('output.txt', 'w') fout.write(help('modules')) 我不知道什么是pbcopy,但我认为这会起作用: python -c 'import urllib; help(urllib)' | pbcopy 至少这确实有效: p
myelf$python帮助('modules')| pbcopy
这是个好主意吗
fout = open('output.txt', 'w')
fout.write(help('modules'))
我不知道什么是pbcopy,但我认为这会起作用:
python -c 'import urllib; help(urllib)' | pbcopy
至少这确实有效:
python -c 'import urllib; help(urllib)' > file
从manpython
:
-c command
Specify the command to execute (see next section). This terminates the option list (following options are passed as arguments to the command).
更新:
要将其复制到剪贴板,您可以将其添加到~/.bashrc
:
pc() { python -c "import $1; help($1);" | xclip -i -selection clipboard; }
然后只需调用pc日志
或pc my\u模块
或者您可以通过管道将其传送到pbcopy或任何适合您的工具。用于查找文档并打印文档
例如:
$ python -c 'import pydoc; print pydoc.getdoc(id)'
id(object) -> integer
Return the identity of an object. This is guaranteed to be unique among
simultaneously existing objects. (Hint: it's the object's memory address.)
在我的Ubuntu上,也希望在你的boxen上(因为它是python的一个标准特性),有一个方便的命令,因此很容易键入
pydoc modules | pbcopy
pbcopy
允许您通过管道将输出传送到控制台,并将其传送到剪贴板。