由于网上查找了好多帖子都没有明确解决方案,想分享出来给大家:
大部分能找到的帖子,都会有这句代码让大家引用,用来进行用户登录操作
name, authentication_status, username = authenticator.login('Login', 'main')
但实际运行时会报错为:
the 'form_name' parameter has been replaced with the 'fields'
通过查找GITHUB,有说明如下:
Authenticate.login
Parameters:
- location: str, {'main', 'sidebar'}, default 'main'
- Specifies the location of the login widget.
- max_concurrent_users: int, default None
- Limits the number of concurrent users. If not specified there will be no limit to the number of users.
- max_login_attempts: int, default None
- Limits the number of failed login attempts. If not specified there will be no limit to the number of failed login attempts.
- fields: dict, default {'Form name':'Login', 'Username':'Username', 'Password':'Password', 'Login':'Login'}
- Customizes the text of headers, buttons and other fields.
- clear_on_submit: bool, default False
- Specifies the clear on submit setting, True: clears inputs on submit, False: keeps inputs on submit.
很明显,我们的传参是有问题的,这里我是这么处理的:
name, authentication_status, username = authenticator.login('main',None,None,{'Form name':'Login', 'Username':'Username', 'Password':'Password', 'Login':'Login'},False)
运行后,登录成功!