我想在一个内置模块中打印所有可用的函数和子模块。 例如:
dir(__import__("sys"))
它给出了类和方法的列表。你知道吗
['__displayhook__',
'__doc__',
'__egginsert',
'__excepthook__',
'__name__',
'__package__',
'__plen',
'__stderr__',
'__stdin__',
'__stdout__',
'argv',
'builtin_module_names',
'byteorder',
'call_tracing',
'stdin',
'stdout',
'subversion',
'version',
'version_info',
'warnoptions',
'winver'] ...etc
但是我想检查类中所有可用的方法标准输入即
标准输入包含以下函数
sys.stdin.close
sys.stdin.name
sys.stdin.softspace
sys.stdin.readline
sys.stdin.readlines
sys.stdin.seek ...etc
那么如何打印一个子模块类的所有可用方法。
我很好奇如何实现这一点。
谢谢。
编辑:
module_name = "sys" #module is taken from the user
smod ="stdin" # select the desire sub-module
param = module_name + smod
def printFns(param):
#code to print all the available functions
您可以使用与
sys
模块相同的方法。 i、 e相关问题 更多 >
编程相关推荐