*前的都是位置参数,包括有默认值的位置参数;
*后的都是关键字参数,可以不赋默认值,但是调用函数的时候必须赋值
*后面有默认值的的关键字参数如果要重新赋值,必须以关键字的形式赋值
这里将没有默认值的关键字参数x放在*后面的作用就是,在调用函数的时候必须指名给x赋值。
python中的特殊注释
在注释中使用TODO的作用是进行全局标记,在pycharm下方的工作栏中查看TODO就可以找到这个注释;
我们可以在给变量赋值的时候指定它的类型,比如
a=0 # type:dict
#此时在a.的时候就会提示dict类型的方法
#多个值的情况
x,y=1,2 #type:str,dict
#函数中参数的情况:
def func(a:str,b:dict):
pass
#或者
def funcc(a,b):
'''
param str a:
param dict b:
'''
pass
当然这样指定类型只是一种提示和建议,在实际赋值时,也可以赋其他类型的值,不会报错