1 Star 0 Fork 0

dotzhen/PythonStudyAssignment

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
check_attr.py 387 Bytes
一键复制 编辑 原始数据 按行查看 历史
dotzhen 提交于 2023-01-13 23:37 +08:00 . 提交第8周作业
import importlib
import sys
module_name = sys.argv[1]
attr_name = sys.argv[2]
try:
module = importlib.import_module(module_name)
if hasattr(module, attr_name):
print(f"{module_name} module has {attr_name} attribute.")
else:
print(f"{module_name} module does not have {attr_name} attribute.")
except ImportError:
print(f"{module_name} module not found.")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dotzhen/python-study-assignment.git
git@gitee.com:dotzhen/python-study-assignment.git
dotzhen
python-study-assignment
PythonStudyAssignment
master

搜索帮助