首页 > 解决方案 > 从 python 模块导入变量

问题描述

我在 python 中有一个名为 tb_batch 的模块。内容是:

m_d = dt.datetime.now().strftime('%B') + '_' + str(dt.datetime.now().year)

当我尝试将此变量导入另一个 python 程序时,

from tb_batch import m_d

它抛出错误:

AttributeError: module 'tb_batch' has no attribute 'm_d'

我究竟做错了什么?

标签: pythonjupyter-notebookpython-import

解决方案


I think the problem here is with jupyter cells. I have run my code in VisualStudioCode and it is working fine. Thanks all for your contribution


推荐阅读