Python函数调用:

函数调用:
1,默认参数放在参数列表的最后
2,ham:str 第一个是参数,第二个是自己的注释,一般写参数类型
    ->后写的是返回值的类型
3,返回只能是一个返回值,这里采用元组的方式来完成了多个变量的传回
函数名._annotations_表达的是注释


def f(ham: str , jacki: 1 , eggs: str = 'eggss') -> float:
    print( "Annotations:" , f. __annotations__)
    print( "Arguments:" , ham , eggs ,jacki)
#eggs=22
    jacki= 2
    return eggs + ' and ' + ham ,jacki

str2=f( 'spam' , "jackey")
str3= 99
print(str2 ,str3)

猜你喜欢

转载自blog.csdn.net/qq_24265945/article/details/80989043