python redirect函数怎么用?

480次阅读
没有评论

python 

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

描述:

跳转指定的url

语法:

redirect();

参数:

path

实例使用:

from flask import redirect
def redirect(path):
    header = 'HTTP/1.1 302 JUMP\r\nContent-Type: text/html\r\n'
    location = 'Location: {}'.format(path)
    response = header + location
return response.encode('utf-8')

《相关推荐:php框架》

上述我们可以获知信息,我们可以跳转到新的链接里,需要使用from flask import redirect导入,才可以正式进行函数的使用。

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:Python基础教程2022-12-07发表,共计401字。
新手QQ群:570568346,欢迎进群讨论 Python51学习