python - 从 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'
我究竟做错了什么?
解决方案
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
推荐阅读
- pytorch - fastai 表格模型训练但找不到分类映射
- python - 为什么 Apache 服务器在 python 中使用雪花摄取模块引发语法错误
- amazon-s3 - 将静态站点部署到 AWS S3 的 Github 操作
- java - (Java) 如何存储我的 x 和 y 值以在 for 循环之外使用它们?
- javascript - 在 Jquery 中获取匹配的类
- javascript - 在 PHP 和 Ajax 中使用 Json 传递值
- python - Python 可以正常执行语句,但是从 freeradius 模块/Rlm_python 运行时,相同的语句使模块失败
- web-api-testing - 是否有 Mozilla marionette 协议命令的文档?
- c++ - CLion 中 clang 格式的 RawStringFormats 错误
- macos - 如何在 MacOS 上从 Atom IDE 构建 Rust?