jsonToUrlCode.py 478 Bytes
# -*- coding: utf-8 -*-

# @Time    : 2021/8/4 14:33
# @Author  : Ljq
# @File    : jsonToUrlcode.py
# @Software: PyCharm

"""

"""

import urllib.parse

def jsonToUrlcode(data_json={}):
    """json格式数据转换未urlcode格式数据"""
    data_uc = ""
    for k, v in data_json.items():
        data_uc = data_uc + str(k) + "=" + urllib.parse.quote(str(v)) + "&"
    print(data_uc)
    return data_uc

# data_json = {"a": "a1", "b": "b1"}
# print(jsonToUrlcode(data_json))