Flask:在full_路径中替换GET参数值的好方法

2024-10-02 22:23:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我们有一个具有以下值的full_path = request.full_path

/v1/helloworld?year=2020&key=123&language=in&country=ID

我们想用以下值替换langaugeGET参数值

/v1/helloworld?year=2020&key=123&language=id&country=ID

目前,我们正在使用以下方法

full_path = request.full_path
if 'in' == request.args.get('language'):
    full_path = full_path.replace("language=in", "language=id")

我们对使用字符串replace来完成这项工作不是特别舒服。我想知道,有没有其他更好的方法来实现这一目标


Tags: path方法keyinidrequestyearlanguage