You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en-us/api/QuecPythonThirdlib.md
+61-6Lines changed: 61 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -598,6 +598,15 @@ Send the POST request
598
598
| decode | bool | (Optional)True decode the response content and return the str type. False turn off decoding and return bytes type. Default: True. (It is only used with response content). ||
599
599
| sizeof | int | (Optional. Read the data in the buffer. Default: 255. Unit: byte. The larger the value, the faster the reading speeding. ( It is recommended to 255-4096 bytes because there may be the possibility of data loss if data setting is too large.) ||
600
600
601
+
* Content-Type explanation:
602
+
603
+
When using the POST method to submit data, the submitted data mainly has the following four forms:
604
+
605
+
- application/x-www-form-urlencoded:The form data is encoded in key/value format and sent to the server (the default format of the submitted data in the form)
606
+
- multipart/form-data : When you need to upload files in the form, you need to use this format
607
+
- application/json: JSON data format
608
+
- application/octet-stream :Binary stream data (such as common file downloads)
Use the POST method to upload files to FTP. Currently, only uploads in the form of "multipart/form-data" are supported, and the default headers are "multipart/form-data".
| files | dict | The dict type parameter must contain "filepath (device file path)" and "filename (file name)" |
659
+
| headers | dict | (Optional parameter) The request header, the default is None, and the default Content-Type is "multipart/form-data" when uploading files. Currently, only "multipart/form-data" is supported. |
660
+
661
+
* Example
662
+
663
+
```python
664
+
import request
665
+
666
+
url =''# FTP service address, you need to enter an existing file path, for example: http://upload.file.com/folder
1.After using the returned response object to read the data once in text/content/json() etc., it cannot be read again
770
+
2.The response.text and response.content methods return an iterator object (Iterable: All elements that can be traversed by a for loop can be called an iterable object), because the content returned by the request is considered too So we use the method of returning iterator to deal with, you can use the for loop to traverse the returned results, the example is as follows
771
+
'''
772
+
# response.text
773
+
response = request.get(url) # Support ssl
774
+
for i in response.text: # response.content is an iterator object
775
+
print(i)
776
+
# response.content
777
+
response = request.get(url)
778
+
for i in response.content: # response.content is an iterator object
729
779
print(i)
780
+
# response.json
781
+
url ="http://httpbin.org/post"
782
+
data = {"key1": "value1", "key2": "value2", "key3": "value3"}
783
+
response = request.post(url, data=ujson.dumps(data)) # Send HTTP POST request
0 commit comments