1 Star 2 Fork 1

xi2p/eatNote

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo.py 915 Bytes
一键复制 编辑 原始数据 按行查看 历史
xi2p 提交于 2022-02-01 17:55 +08:00 . commit
class DEMO:
"""
常量
"""
def __init__(self, v, _type):
if not isinstance(v, dict):
self._value = {_type: v}
else:
self._value = v
def __or__(self, other):
return DEMO(self.value | other.value, '_')
@property
def value(self):
return self._value
def __contains__(self, item):
for _key in item.value.keys():
_value = item.value[_key]
if _key in self._value.keys():
if self._value[_key] == _value:
pass # 可以
else:
return False
else:
return False
return True
def __eq__(self, other):
return True if self._value == other.value else False
a = DEMO(1, "a")
print(a.value)
b = DEMO(2, "b")
c = DEMO(3, "b")
print(((a | b) | c).value)
print(a in (a|b))
print(a == a)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xi2p/eat-note.git
git@gitee.com:xi2p/eat-note.git
xi2p
eat-note
eatNote
master

搜索帮助