【发布时间】:2020-11-29 14:39:09
【问题描述】:
我想根据 CLI 参数将 python 脚本/模块导入到我的脚本中。我想要这样的东西:
import os
import sys
from sys.argv[1] import ClassName
# Rest of the function using the class ClassName
然后我想从 CLI 调用我想要的任何模块(在我的例子中是机器学习模型):
python3 script.py model_1
有没有办法在 python 中做到这一点?
【问题讨论】:
标签: python python-3.x command-line-arguments