在 Python 3.12 中,我们有如下类型别名:
Python 3.12.4+ (heads/3.12:99bc8589f0, Jul 27 2024, 11:20:07) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> type S = str
>>> S
S
根据这种语法,我假设从现在起该词type
被视为关键字,但事实并非如此:
>>> type = 2
>>>
并且:
>>> import keyword
>>> keyword.iskeyword('type')
False