Skip to main content
 首页 » 编程设计

python之args : def func(value:str) 之后的两个点和一个类是什么意思

2024年10月17日10luoye11

<分区>

我不明白 arg: str 是什么意思

def hello(arg: str): 
    print(type(arg)) 
    print('do stuff!', arg) 
 
 
hello('something') 

我以为是在指定一个类型,但我试着调用 hello,我没有任何异常。我尝试用 int 调用 hello,没有错误。

我做了一些测试,但我还没有想出任何东西......

知道这是在做什么吗?

马特