草庐IT

show-hide

全部标签

python - 为什么 'pip show' 或 'pip list' 对我不起作用?

Python的pip正在为我安装和更新包,但似乎不支持一些记录的命令(至少在OS10.8.2和Python2.7上运行1.2.1。2).当我尝试piplist或pipshow我明白了Usage:pipCOMMAND[OPTIONS]Nocommandbythenamepip(maybeyoumeant"pipinstall")这些命令是否尚未实现(尽管已记录在案)? 最佳答案 您正在寻找的新功能是最近的——它们在1.2.1.post1中,但不在1.2.1中,您可能正在查看的文档(http://www.pip-installer.or

python - Jupyter,交互式 Matplotlib : Hide the toolbar of the interactive view

我开始使用Matplotlib中的交互式绘图:%matplotlibnotebookimportmatplotlib.pyplotaspltfig,axes=plt.subplots(1,figsize=(8,3))plt.plot([iforiinrange(10)],np.random.randint(10,size=10))plt.show()谁知道有没有办法隐藏交互模式的工具栏? 最佳答案 我用一些python生成的css禁用了交互模式按钮和工具栏。在其中一个笔记本单元格中运行以下命令:%%html.output_wrapp

python - matplotlib 图形在 show() 和 savefig() 之间消失

我在字典中保留了一组对数字的引用,以便以后需要时可以保存它们。如果调用show()命令并先查看它们,我很烦恼保存的数字是空白的。由于show()命令block并且我没有使用类似spyder的解释器,因此我必须在到达savefig()之前关闭图形figures['myfig_1']=figure()...figures['myfig_n']=figure()...#show()#disablingthismakestheproblemgoawayprint"Saving:"forfiginfigures:figure(figures[fig].number)savefig(fig)pri

python - Sphinx autodoc show-inheritance : How to skip undocumented, 中间基础?

我有一个像这样的三层类结构:classSuper(object):"""Thisclassisdocumented."""classIntermediate(Super):passclassSub(Intermediate):"""Thisisalsodocumented."""我的index.rst文件如下所示:..automodule::mymodule:show-inheritance::inherited-members:Sphinx为我生成了一份不错的API文档。它包括类Super和Sub,并带有适当的注释。它不包括Intermediate,因为它没有注释而且我没有提供und

python - 如何将 "show details"按钮添加到 tkinter 消息框?

我有一个Python脚本,它使用tkinter.messagebox在发生意外异常时显示带有回溯详细信息的错误消息。importtkinter.messageboxastmimporttracebacktry:1/0exceptExceptionaserror:tm.showerror(title="Error",message="Anerrorhasoccurred:'"+str(error)+"'.",detail=traceback.format_exc())以这种方式显示回溯有一些缺点。追溯细节aren'thelpfulfortheaverageuser.测试人员无法轻松地从消

python - Argparse 子解析器 : hide metavar in command listing

我在我的程序中使用Pythonargparse模块作为命令行子命令。我的代码基本上是这样的:importargparseparser=argparse.ArgumentParser()subparsers=parser.add_subparsers(title="subcommands",metavar="")subparser=subparsers.add_parser("this",help="dothis")subparser=subparsers.add_parser("that",help="dothat")parser.parse_args()运行“pythontest.p

python - 使用 matplotlib 中的 show() 和 close()

我在使用matplotlib时遇到了一些问题....我无法一次打开2个窗口来显示带有show()的图像,似乎脚本在我使用show的那一行停止并且不会继续,除非我手动关闭显示。有没有办法关闭脚本中的图形窗口?以下代码没有按我的意愿运行:importmatplotlib.pyplotaspltfromtimeimportsleepfromscipyimporteyeplt.imshow(eye(3))plt.show()sleep(1)plt.close()plt.imshow(eye(2))plt.show()我预计第一个窗口会在1秒后关闭,然后打开第二个窗口,但直到我自己关闭它后窗El

Python:通过 SSH 连接到 Cisco 设备并运行 show 命令

我已广泛阅读这篇文章并研究了Exscript、paramiko、Fabric和pxssh,但我仍然迷路PersistentsshsessiontoCiscorouter.我是python脚本的新手。我正在尝试用Python编写一个脚本,它将通过SSH连接到Cisco设备,运行“显示版本”,在记事本中显示结果,然后结束脚本。我可以使用不需要用户与设备交互的显示命令来实现这一点。例如:fromExscript.util.interactimportread_loginfromExscript.protocolsimportSSH2account=read_login()conn=SSH2(

python - 绘图 : show only first 3 lines in legend

我运行了200次模拟,并将3个输出列表绘制为3条高透明度的线。这使我能够显示模拟之间的差异。问题是我的图例显示3x200项而不是3项。如何让它为每行显示一次图例?forsimulationinrange(200):plt.plot(num_s_nodes,label="susceptible",color="blue",alpha=0.02)plt.plot(num_r_nodes,label="recovered",color="green",alpha=0.02)plt.plot(num_i_nodes,label="infected",color="red",alpha=0.02

python - 在 Python 中调试 : Show last N executed lines

我很想看看在这个异常发生之前python解释器执行的最后10行:test_has_perm_in_foobar.pyFTraceback(mostrecentcalllast):File"/.../test_has_perm_in_foobar.py",line50,intest_has_permself.assertFalse(check_perm(request,some_object))File"/usr/lib/python2.7/unittest/case.py",line416,inassertFalseraiseself.failureException(msg)Asse