【问题标题】:What does the colon inside the parameter mean? [duplicate]参数里面的冒号是什么意思? [复制]
【发布时间】:2017-05-29 15:12:18
【问题描述】:

words_pron_dict:str 上的冒号是什么意思?我在 python 2.7 上遇到语法错误。是蟒蛇3吗?我该如何使用它?

class TextToSpeech:
    CHUNK = 1024

    def __init__(self, words_pron_dict:str = 'cmudict-0.7b.txt'):
        self._l = {}
        self._load_words(words_pron_dict)

【问题讨论】:

  • 只需删除:str,它就可以在python 2中工作(这是python 3.5的一个新功能来检查类型)

标签: python


【解决方案1】:

这是一个类型注解:https://docs.python.org/3/library/typing.html

你应该可以删除它。

【讨论】:

    猜你喜欢
    • 2018-11-21
    • 1970-01-01
    • 2011-03-31
    • 2011-01-17
    • 2016-12-23
    • 2012-10-09
    • 2012-06-27
    相关资源
    最近更新 更多