【发布时间】:2022-12-19 20:36:49
【问题描述】:
我正在尝试使用控制台匹配 Python 3.10 中的类型:
t = 12.0
match type(t):
case int:
print("int")
case float:
print("float")
我得到这个错误:
File "<stdin>", line 2
SyntaxError: name capture 'int' makes remaining patterns unreachable
我该如何解决这个问题?
【问题讨论】:
标签: types pattern-matching python-3.10