0%

Python小知识

1. 获取指定方法的参数信息

1
2
3
4
5
6
7
8
9
def user_add(username, password, **kwargs):
print('username:', username, ', password:', password)

argspec = inspect.getfullargspec(user_add)
print(argspec)
#output: FullArgSpec(args=['username', 'password'], varargs=None, varkw='kwargs', defaults=None, kwonlyargs=[], kwonlydefaults=None, annotations={})

print(argspec[0])
#output: ['username', 'password']