从python模块导入变量

从python模块导入变量,python,jupyter-notebook,python-import,Python,Jupyter Notebook,Python Import,我在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' 我做错了什么?我认为这里的问题在于jupyter细胞。

我在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'

我做错了什么?

我认为这里的问题在于jupyter细胞。我已经在VisualStudioCode中运行了我的代码,它运行得很好。感谢大家的贡献

无法重现错误,在我这方面效果非常好(使用
tb_batch.py
包含
import datetime as dt
和您引用的行)。你能为我们制作一个显示错误的屏幕吗?我正在使用jupyter笔记本电脑。当我在Visual studio代码中尝试相同的代码时,它在()1导入tb\U批处理-->2打印(tb\U批处理.tb\U路径)AttributeError:module'tb\U batch'没有属性'tb\U path'
AttributeError Traceback中非常有效(最近一次调用最后一次)in()--->1 tb\u batch.m\u d attributeer错误:模块“tb\u batch”没有属性“m\u d”
我在这方面没有太多经验。请将其标记为这样,以便具有相关专业知识的人员可以更容易地找到您的问题。