[英]Passing “local” variables in Python by changing and importing modules?
[英]Importing variables from python modules
我在 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 中运行了我的代码,它运行良好。 感谢大家的贡献
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.