我对python类型的注释有一点理解上的问题。考虑以下用于将字典转换为标准化格式的函数 from __future__ import annotations # needed for type annotations in > python 3.7normalized_dict[key] = [producers[key]]
return normalized_dict 此示例导致normalized_dict的赋值出现类型问题,没有出
open(name.lower() + "profile.txt", "r")import timewindow.title("Pythontitle1 = Tkinter.Label(window, text="--Log in to play the Python Games-- \n", bg="#39d972")
usertitle
我正在尝试理解如何使用Python3.9类型提示来注释一个接收带有可选或多个类型值的dict的函数。我知道有了键入模块,我就可以很容易地使用Union和Optional。但我想知道是否可以仅使用Python3.9注释来实现这一点。我在PEP 585上没有找到任何关于这件事的东西。 参考:How should I use the Optional type hint?