![](/img/trans.png)
[英]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.