国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

requests 庫:發(fā)送 form-data 格式的 http 請(qǐng)求 (python)

這篇具有很好參考價(jià)值的文章主要介紹了requests 庫:發(fā)送 form-data 格式的 http 請(qǐng)求 (python)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

安裝 requests-toolbelt

!pip install requests-toolbelt

demo

from requests_toolbelt import MultipartEncoder
import requests

m = MultipartEncoder(
    fields={'query': """
    第一,向量化匹配是有能力上限的。搜索引擎實(shí)現(xiàn)語義搜索已經(jīng)是好幾年的事情了,為什么一直無法上線,自然有他的匹配精確度瓶頸問題。
    第二,本質(zhì)是匹配問題(即找到語義相似知識(shí)),NLP領(lǐng)域原本也有更優(yōu)美,更高效的方案,只是這波熱潮里,很多以前沒接觸過AI的朋友對(duì)之不熟悉罷了。
    第三,甚至不用AI技術(shù),用精確MVSOL、用策略規(guī)則也是一種解法,其至是重要解法。舊AI時(shí)代的產(chǎn)品同學(xué)會(huì)非常熟悉這種“用規(guī)則/策略/產(chǎn)品設(shè)計(jì)”來彌補(bǔ)AI能力贏弱的問題一一現(xiàn)在是因?yàn)樾袠I(yè)早期,大家被LLM的能力錯(cuò)誤迷惑,并且以往產(chǎn)品經(jīng)理的聲音還沒發(fā)出來而已。
    其次,在引入外部知識(shí)這個(gè)事情上,如果是特別專業(yè)的領(lǐng)域,純粹依賴向量、NLP、策略/規(guī)則在某些場(chǎng)景仍然不奏效。因?yàn)槟P褪紫刃枰莆漳莻€(gè)領(lǐng)域的專業(yè)知識(shí),才能在這樣一個(gè)基礎(chǔ)能力的加持下,用向量化等手段來便捷地解決外部知識(shí)引入問題。
    當(dāng)在模型在基礎(chǔ)知識(shí)中缺乏、或有錯(cuò)誤地學(xué)習(xí)到某些背景知識(shí),即使他有外部知識(shí)庫加持也是無效的最后,不要管是不是90%會(huì)被解決,對(duì)于某個(gè)具體業(yè)務(wù)而言,沒有90%,只有100%0%;"""}
    )

r = requests.post('http://*.*.*.*:8788/translate_zh2en',
                  data=m,
                  headers={'Content-Type': m.content_type})
print(r.text)

response

{"code":10000,
"res":"First, vectorized matching has an upper limit of capability. Implementing semantic search in search engines has been a thing for several years, but why has it not been launched? There naturally exists a bottleneck issue with its matching accuracy.\n\nSecond, the essence is a matching problem (i.e., finding semantically similar knowledge). The NLP field originally had more elegant and efficient solutions, but in this wave of enthusiasm, many friends who had not previously been exposed to AI are simply unfamiliar with it.\n\nThird, even without AI technology, using precise MVSOL or strategic rules is also a solution, and it is an important solution at that. Product colleagues from the old AI era are very familiar with using \"rules/strategies/product design\" to compensate for the weak capabilities of AI. The reason it is not being used now is because the industry is still in its early stages, and everyone has been misled by the capabilities of LLM, and the voices of past product managers have not yet been heard.\n\nFurthermore, when it comes to introducing external knowledge, if it is in a particularly specialized field, purely relying on vectors, NLP, and strategies/rules may still not be effective in certain scenarios. This is because the model first needs to master the specialized knowledge of that field in order to conveniently solve the problem of introducing external knowledge using methods such as vectorization.\n\nWhen the model lacks basic knowledge or has learned certain background knowledge incorrectly, even with the support of an external knowledge base, it will be ineffective in the end. Regardless of whether it can solve 90% of the cases, for a specific business, there is no 90%, only 100% and 0%.",
"time_cost":13.629586219787598}

參考

requests官方網(wǎng)站地址
requests_toolbelt
Python自動(dòng)化 requests 庫:發(fā)送 form-data 格式的 http 請(qǐng)求
requests-toolbelt · PyPI文章來源地址http://www.zghlxwxcb.cn/news/detail-771802.html

到了這里,關(guān)于requests 庫:發(fā)送 form-data 格式的 http 請(qǐng)求 (python)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • java 發(fā)送 http 文件 post,form-data格式的數(shù)據(jù),MultipartEntityBuilder addTextBody中文亂碼

    java 發(fā)送 http 文件 post,form-data格式的數(shù)據(jù),MultipartEntityBuilder addTextBody中文亂碼

    平常我們對(duì)接第三方都是以json的數(shù)據(jù)進(jìn)行數(shù)據(jù)交互的,這次第三方接口只支持form-data格式的表單數(shù)據(jù),傳json數(shù)據(jù)對(duì)方不支持,通過百度和嘗試各種方案最終完美解決,后期再慢慢優(yōu)化吧。還有一個(gè)問題,數(shù)據(jù)中包含中文的戶,到第三方是亂碼的,經(jīng)過百度參考前輩的經(jīng)驗(yàn),

    2024年02月13日
    瀏覽(22)
  • python使用requests提交post請(qǐng)求并上傳文件(multipart/form-data)

    python使用requests提交post請(qǐng)求并上傳文件(multipart/form-data)

    目錄 一、背景 二、請(qǐng)求接口上傳文件 ? ? ? ? 2.1、分析接口 ? ? ? ? 2.2、python進(jìn)行請(qǐng)求 三、總結(jié) ? ? ? ? 也是前幾天,有一個(gè)需求上傳文件需要自動(dòng)化。具體是上傳到系統(tǒng)一個(gè)文件,并收到返回結(jié)果??紤]使用python的requests,一般這種查詢或上傳文件的接口都是post請(qǐng)求。

    2024年02月12日
    瀏覽(19)
  • Java發(fā)送form-data請(qǐng)求

    在Java中發(fā)送form-data請(qǐng)求,可以使用Apache HttpClient或OkHttp這樣的HTTP客戶端庫來發(fā)送請(qǐng)求。 1.添加依賴 2.代碼 對(duì)于HttpClient對(duì)象,HttpClientBuilder.create().build()創(chuàng)建的實(shí)例是 不需要手動(dòng)關(guān)閉 的。 在使用HttpClientBuilder創(chuàng)建HttpClient對(duì)象時(shí),不需要手動(dòng)關(guān)閉HttpClient對(duì)象。這是因?yàn)镠ttpCli

    2024年02月10日
    瀏覽(24)
  • java發(fā)送form-data請(qǐng)求實(shí)現(xiàn)文件上傳

    java發(fā)送form-data請(qǐng)求實(shí)現(xiàn)文件上傳

    需要請(qǐng)求第三方接口上傳文件,該請(qǐng)求類型是form-data請(qǐng)求 ? 注意: 這里的 builder.addPart(\\\"sendfile\\\", new FileBody(file)); , multipartFile 對(duì)應(yīng)form表單的字段名稱。 參考:Java發(fā)送form-data請(qǐng)求實(shí)現(xiàn)文件上傳_IceFloe_Rot的博客-CSDN博客

    2024年01月18日
    瀏覽(21)
  • Java請(qǐng)求調(diào)用參數(shù)格式為form-data類型的接口

    Java請(qǐng)求調(diào)用參數(shù)格式為form-data類型的接口

    接口參數(shù)使用postman調(diào)用如圖所示,只能使用form-data格式調(diào)用 使用java代碼發(fā)送http請(qǐng)求實(shí)現(xiàn)此種方式的接口調(diào)用 特別說明:form的Content-Type屬性為編碼方式 常用有兩種 :application/x-www-form-urlencoded和multipart/form-data,默認(rèn)為application/x-www-form-urlencoded。 x-www-form-urlencoded :當(dāng)action為

    2024年02月12日
    瀏覽(24)
  • post請(qǐng)求設(shè)置表單form-data格式的幾種方式

    post請(qǐng)求設(shè)置表單form-data格式的幾種方式

    我用默認(rèn)的post方法發(fā)送數(shù)據(jù)的時(shí)候發(fā)現(xiàn)后端獲取不到數(shù)據(jù),然而在network中看到參數(shù)是的確傳出去的了。而且用postman測(cè)試的時(shí)候也是可以的,比較了下兩個(gè)的不同發(fā)現(xiàn)是postman使用的是form-data格式,于是用form-data格式再次請(qǐng)求,發(fā)現(xiàn)OJBK 這兩種格式都是無法使用的: ? 方法一:

    2024年02月11日
    瀏覽(29)
  • 關(guān)于form-data和http請(qǐng)求body&網(wǎng)關(guān)處理

    場(chǎng)景 【在http過網(wǎng)關(guān)時(shí),修改內(nèi)容】 在網(wǎng)關(guān)過濾器中,監(jiān)聽所有http請(qǐng)求,截獲請(qǐng)求,并且修改body中內(nèi)容。添加一組用戶憑證,然后通過網(wǎng)關(guān)走向后臺(tái)服務(wù) 使用applicaon/json的請(qǐng)求時(shí),能很好的解決 使用form-data時(shí),body采用下面的 \\\'boundary—\\\'限定邊界,加入?yún)?shù)的形式進(jìn)行傳遞

    2024年02月08日
    瀏覽(23)
  • 使用postman發(fā)送請(qǐng)求,提示Content type ‘multipart/form-data not supported

    使用postman發(fā)送請(qǐng)求,提示Content type ‘multipart/form-data not supported

    1、原因:后端通過@RequestBody 的方式接收參數(shù),不能通過form-data方式傳參,每一個(gè)請(qǐng)求必須是通過實(shí)體對(duì)象進(jìn)行傳參,需要改為使用json傳參

    2024年01月22日
    瀏覽(20)
  • postman 發(fā)送post請(qǐng)求中的x-www-form-urlencoded和form-data的區(qū)別
  • python-用form-data形式上傳文件請(qǐng)求

    python-用form-data形式上傳文件請(qǐng)求

    雖然現(xiàn)在基本上都約定俗成的接口都用json形式請(qǐng)求 但是不可避免地 有些接口需要傳文件流,此時(shí)就需要用form-data形式上傳了 for.e: 存在以下接口,通過接口創(chuàng)建海報(bào)圖 但需要上傳縮略圖, 此時(shí)接口的Content-Type就不能是application/json,而是multipart/form-data; 參數(shù)格式也是以表單

    2023年04月08日
    瀏覽(17)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包