为什么类型检查在Python 3中不起作用?
我已经使用类型检查或提示完成了以下代码:
import typing
def hello(message: str):
print(type(message))
print(message)
hello('Hello!')
hello(1)
hello(1.1)
Run Code Online (Sandbox Code Playgroud)
它产生有效的输出(但int或float上没有错误)。
<class 'str'>
Hello!
<class 'int'>
1
<class 'float'>
1.1
Run Code Online (Sandbox Code Playgroud)
为什么这样工作?也许我不理解输入模块和Python提示。