Check if a parameter is a Python module?

后端 未结 6 524
野性不改
野性不改 2021-02-04 23:54

How can I (pythonically) check if a parameter is a Python module? There\'s no type like module or package.

>>> os


        
6条回答
  •  既然无缘
    2021-02-05 00:42

    This seems a bit hacky, but:

    >>> import sys
    >>> import os
    >>> type(os) is type(sys)
    True
    

提交回复
热议问题