简体   繁体   English

如何在终端中打印所有可用的python标准库方法

[英]How to print all available python standard library methods in the terminal

I am trying to figure out how to list out all the standard library functions/methods (still learning the difference, I'm a noob). 我试图弄清楚如何列出所有标准库函数/方法(仍在学习区别,我是菜鸟)。 So I get how to import a module and use dir() and help(). 因此,我了解了如何导入模块并使用dir()和help()。 These have been a great help and when I try to rewrite a program I learned to write and I get lost I try to use the dir() and help() to spark my memory. 这些提供了很大的帮助,当我尝试重写我学会编写的程序时,迷路了,我尝试使用dir()和help()激发我的记忆。

However, for example, I was re-looking through some code and I had .replace() and I was scouring through my imported modules to find it and then found out it's in the standard library and a sub-part of the str() function. 但是,例如,我正在查看一些代码,并使用了.replace(),并在导入的模块中进行了搜索以查找它,然后在标准库和str()的子部分中找到它。功能。 Is there something I can type into dir() that will spit out str()? 有什么我可以输入dir()的东西来吐出str()吗?

How can I print out all top level built in function/methods like I would when I do dir(re)? 如何像执行dir(re)一样打印出所有内置的函数/方法顶层?

I've tried re-wording this question in search engines several ways and I can't find anything and the results get muddied with "python list _____". 我试图以几种方式在搜索引擎中重新措词这个问题,但我什么都找不到,结果与“ python list _____”混为一谈。

Thanks so much! 非常感谢!

Is there something I can type into dir() that will spit out str()? 有什么我可以输入dir()的东西来吐出str()吗?

dir() on a value of that type. dir()对该类型的值。

dir('hello') # string methods
dir(5) # integer methods
dir([]) # list methods

Ah, I never tried typing just "dir()" that listed I could put in dir(__builtins__) and that is what I was looking for. 啊,我从未尝试只输入列出可以放入dir(__ builtins__)的“ dir()”,而这正是我想要的。 I'll leave it here in case someone else is a noob too and knows where they can start. 如果其他人也是新手,并且知道他们可以从哪里开始,我会把它留在这里。 Just start with dir() and go down the rabbit hole! 只需从dir()开始,然后进入兔子洞!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM