Python查看某个模块or方法的使用方法

1. dir()方法

dir(module or function_name)

import random
dir(random)

2. help()方法查看

import random
help(random)

3. random._file_

会列出模块所在路径,可以打开相应路径阅读源码。在Windows下的Pycharm里面也可以直接用Ctrl+B来跳转到源代码。

import random
random.__file__

4. ?function

import random
?random.choice

5. 官网

https://www.python.org/

6. github源代码

有一些内置函数需要阅读CPython源代码,网址:https://github.com/python/cpython

发布了128 篇原创文章 · 获赞 157 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/qq_27283619/article/details/101317781