gpt4 book ai didi

python - 数据作为 Python 中对象之间的关系

转载 作者:行者123 更新时间:2023-11-28 17:28:50 24 4
gpt4 key购买 nike

章节Data ModelPython 文档语言引用 部分说:

All data in a Python program is represented by objects or by relations between objects.

我理解Python程序中所有数据都由对象表示的部分。但是对象之间的关系表示什么数据?

谁能举个例子解释一下?

最佳答案

But what data is represented by relations between objects?

例如,在

d = {2: 'b'}

关系是对象2映射到字典d中的对象'b'

l = [2, 'b']

关系是对象 2b 是列表 l 的 0 和 1 成员。

class Foo(object):
def __init__(self, x):
self._x = x

f = Foo(2)

关系是对象2f的成员_x

关于python - 数据作为 Python 中对象之间的关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36240238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com