【发布时间】:2018-08-05 21:48:27
【问题描述】:
有没有办法通知 python (3.6+) 我的属性是某个东西的字典?
我想要什么:
def classify(self, sentenses: dict(Sentence)): # <-- dict of Sentence
for s in sentences:
a = s.attribute
【问题讨论】:
-
见the documentation,例如
Dict[str, Sentence] -
你从什么映射到什么?
-
"a dict of something" 是模棱两可的。你的意思是
Sentence作为键(用其他具体或通用的东西作为值)还是作为值?
标签: python python-3.x data-structures types type-hinting