如何通过python模块获取字典数据?

How to get dictionary data through a python module?

def cd():
     person = {
    'name' : 'bhavya',
    'age' : 32,
    'birth_date' : '18/10/1996'
    }
    print(person)

cd()

这是我保存为 ey.py 的字典。 现在我想在模块的帮助下将整个数据导入另一个 .py 文件。所以我可以获取保存在 ey.py.

中的全部数据

谁能指导我?

如果您的目标是将数据与主要 python 代码分开,则必须制作新的 python 代码(例如 data.py

data.py

def get_data():
    data = { 'name' : 'bhavya', 'age' : 32, 'birth_date' : '18/10/1996' }
    return data

main.py

from data import get_data

person = get_data()
print(person)

FYI