[Python] How to pass already existing variable in raw form in request python [closed]

Discussão em 'Python' iniciado por Stack, Fevereiro 7, 2025.

  1. Stack

    Stack Membro Participativo

    from curl_cffi import requests
    cookies = {

    }
    params = {
    "device_platform": "web",
    "app_id": "3001",
    "version_code": "22202",
    "biz_id": "0",
    "uuid": "1630e75e-112a-4c7b-bd42-a419f40b3371",
    "lang": "en",
    "device_id": "339857869057830914",
    "os_name": "Mac",
    "browser_name": "chrome",
    "device_memory": "8",
    "cpu_core_num": "11",
    "browser_language": "en-GB",
    "browser_platform": "MacIntel",
    "screen_width": "3440",
    "screen_height": "1440",
    "unix": "1738752573000"
    }
    headers = {
    "accept": "application/json, text/plain, */*",
    "content-type": "application/json",
    "token": A_LONG_JWT_TOKEN,

    }
    data = r'{"desc":"a man walking","useOriginPrompt":false,"fileList":[],"modelID":"23010","quantity":"1","extra":{"promptStruct":"{\"value\":[{\"type\":\"paragraph\",\"children\":[{\"text\":\"a man walking\"}]}],\"length\":13,\"plainLength\":13,\"rawLength\":13}"}}'

    response = requests.post(
    "https://theapi.com/api/multimodal/generate/video",
    params=params,
    cookies=cookies,
    headers=headers,
    data=data,
    )
    print(response.text)


    The code is working fine the issue is that I already have string data without r'' saved in variable

    I want to convert it raw format and pass it to requests like data = "string" and data = r'existing data string' and use it with requests.

    Continue reading...

Compartilhe esta Página