【发布时间】:2016-09-20 01:39:13
【问题描述】:
我想在我的 Python 程序中使用类型提示。如何为像
这样的复杂数据结构创建类型提示- 字符串列表
- 返回整数的生成器?
示例
def names() -> list:
# I would like to specify that the list contains strings?
return ['Amelie', 'John', 'Carmen']
def numbers():
# Which type should I specify for `numbers()`?
for num in range(100):
yield num
【问题讨论】:
标签: python python-3.5 type-hinting