小编Be3*_*K0T的帖子

为什么Python 3.10中的关键字“match”可以作为变量或函数名?

我不完全理解为什么关键字match可以用作变量或函数名,而不像其他关键字ifwhile等等?

>>> match "abc":
...     case "abc":
...         print('Hello!')
...     
Hello!
>>> from re import match
>>> match('A', 'A Something A')
<re.Match object; span=(0, 1), match='A'>
>>> match = '????'
>>> match
'????'
>>> case = 'something'
>>> case
'something'
Run Code Online (Sandbox Code Playgroud)

python pattern-matching keyword python-3.10

4
推荐指数
1
解决办法
3386
查看次数

标签 统计

keyword ×1

pattern-matching ×1

python ×1

python-3.10 ×1