python - 我想从 main_program.py 修改我自己的 my_dicts.py 模块
问题描述
我处于需要不断向我的代码中添加新字典的情况。所以,为了不把它全部塞进一个 .py 文件中,我决定创建模块 my_dicts.py,把它们都写在那里,然后将它导入 main_program.py。
my_dicts.py 看起来像这样:
dict1 = ...
dict2 = ...
dict3 = ...
.
.
.
main_program.py 看起来像这样:
import my_dicts as d
# loading some data.
.
.
.
# running some functions.
.
.
.
# creating a new dictionary with the purpose of adding it to my_dicts.py
new_dictionary = function_to_create_my_new_dictionary(some_data)
我的问题是:如何在不停止 main_program.py 的情况下将 new_dictionary 添加到 my_dicts.py。
解决方案
推荐阅读
- node.js - 在 mongoDb 中搜索填充的参考数据
- excel - 当值不等于文本时如何查找重复项?
- html - 菜单栏无法缩放到屏幕大小
- reactjs - 如何在 AWS CodeBuild for cypress 中获取正在运行的应用程序 URL
- python - 如何仅将 wait_for("reaction_add") 函数用于特定消息?不和谐.py
- postgresql - 如何将 json 转换为 posgresql.JSONB 类型
- assembly - 如何在汇编语言中划分浮点数(例如.0.19等)
- javascript - mongo 客户端:如何在单独的文件中重用客户端?
- c# - 重叠图表的值以在图表中显示连续的段
- azure-ad-b2c - Azure AD B2C - 在单独的步骤中自定义电子邮件验证