{"id":419020,"date":"2021-03-21T20:33:34","date_gmt":"2021-03-21T12:33:34","guid":{"rendered":"http:\/\/4563.org\/?p=419020"},"modified":"2021-03-21T20:33:34","modified_gmt":"2021-03-21T12:33:34","slug":"%e6%b1%82%e6%95%99%e4%b8%80%e4%b8%aa-python-%e7%88%ac%e8%99%ab%e7%9a%84%e9%97%ae%e9%a2%98%e5%85%b3%e4%ba%8e-form-data-%e7%9a%84%e6%95%b0%e6%8d%ae%e6%80%8e%e4%b9%88%e9%80%9a%e8%bf%87-post-%e4%b8%8a","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=419020","title":{"rendered":"\u6c42\u6559\u4e00\u4e2a Python \u722c\u866b\u7684\u95ee\u9898\u5173\u4e8e form-data \u7684\u6570\u636e\u600e\u4e48\u901a\u8fc7 post \u4e0a\u4f20"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6c42\u6559\u4e00\u4e2a Python \u722c\u866b\u7684\u95ee\u9898\u5173\u4e8e form-data \u7684\u6570\u636e\u600e\u4e48\u901a\u8fc7 post \u4e0a\u4f20               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wkx556874 <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u60f3\u5199\u4e00\u4e2a\u722c\u866b\u81ea\u52a8\u63d0\u4ea4\u4fee\u6539\u67d0\u5e73\u53f0\u7684\u4eba\u5458\u4fe1\u606f\uff0c<br \/>\u6240\u6709\u4fe1\u606f\u90fd\u641e\u61c2\u4e86\uff0c\u4f46\u662f\u6709\u4e00\u9879\u662f\u7167\u7247\u3002<br \/>\u5176\u4ed6\u4f8b\u5982\u624b\u673a\u53f7\u90a3\u4e9b\u6570\u636e\u76f4\u63a5\u5728 data \u5b57\u5178\u91cc\u9762\u58f0\u660e data={&#8220;mobile&#8221;\uff1a&#8221;13000000000&#8221;}\u5c31\u884c\uff0c<br \/>\u8fd9\u662f\u6293\u5305\u6293\u5230\u7684\u6570\u636e\uff1a<br \/>Content-Disposition: form-data; name=&#8221;mobile&#8221;<br \/>Content-Length: 11 13000000000<br \/>\u7136\u540e\u76f4\u63a5 session.post(url, data=data) \u5c31\u76f4\u63a5\u4fee\u6539\u4e86\uff0c<br \/>\u4f46\u662f\u7167\u7247\u5e94\u8be5\u600e\u4e48\u5f04\u5462\uff1f<br \/>\u8fd9\u662f\u6293\u5305\u6293\u5230\u7684\u6570\u636e\uff1a<br \/>Content-Disposition: form-data; name=&#8221;photo&#8221;; filename=&#8221;pic_after_crop_20210328145606.jpg&#8221;<br \/>Content-Type: multipart\/mixed; boundary=BbC04y<br \/>Content-Length: 205722 &lt;file&gt;<br \/>\u6211\u8fd9\u6837\u5199\uff0c\u4fee\u6539\u6ca1\u7528\u3002\u3002<br \/>files = {&#8220;file&#8221;: (&#8220;1.png&#8221;, open(&#8220;1.png&#8221;, &#8220;rb&#8221;), &#8220;image\/png&#8221;)}<br \/>data={&#8220;photo&#8221;: &#8220;1.png&#8221;}<br \/>session.post(url, data=data, files=files)<br \/>\u5e94\u8be5\u600e\u4e48\u5199\u5462\uff1f\u6211\u67e5\u4e86\u5f88\u591a\u6587\u6863\u4e5f\u6ca1\u627e\u5230\u3002\u3002<br \/>\u53ea\u597d\u6765\u95ee\u95ee\u5927\u4f6c\u4eec\u3002      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5591775\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : wkx556874 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6c42\u5927\u4f6c\u4eec\u89e3\u7b54\u4e0b\u5440\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5591776\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : paidaxtis <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             import\u00a0requests<\/p>\n<p>url\u00a0=\u00a0&#8220;\u63a5\u53e3 url&#8221;<\/p>\n<p>payload={}<br \/>files=[<br \/>\u00a0\u00a0(&#8216;file&#8217;,(&#8216;\u56fe\u7247\u540d\u5b57.jpg&#8217;,open(&#8216;\u56fe\u7247 url&#8217;,&#8217;rb&#8217;),&#8217;image\/jpeg&#8217;))<br \/>]<br \/>headers\u00a0=\u00a0{}<\/p>\n<p>response\u00a0=\u00a0requests.request(&#8220;POST&#8221;,\u00a0url,\u00a0headers=headers,\u00a0data=payload,\u00a0files=files)<\/p>\n<p>print(response.text)                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5591777\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : paidaxtis <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             postman \u81ea\u52a8\u751f\u6210\u7684\u4ee3\u7801\uff0c\u6211\u81ea\u5df1\u6d4b\u8bd5\u63a5\u53e3\u8fd9\u6837\u5199\u662f\u53ef\u4ee5\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u6559\u4e00\u4e2a Python \u722c\u866b\u7684\u95ee\u9898&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/419020"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=419020"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/419020\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=419020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=419020"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=419020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}