13. upload files

upload files:

 

= {F 
	"loclUrl": (None, R & lt ( "file path \ pic.jpg")), 
	"imgfile": ( "value of the filename", open (r ( "file path \ pic.jpg", "rb" )), "file type") 
}

 

Direct transfer files = f request, such as: r = s.post (url, files = f)

Note: Attachments upload script on the same path, only the file name to write the file; otherwise, the need to write the path + filename

 

Upload multiple attachments:

When uploading the plurality of attachments, the dictionary can not pass, need to define a list, list of tuples discharge, i.e., f = [(), ()]

 

Third-party modules: requests-toolbelt, can file upload

Example: Zen submit bug, upload attachments (to be supplemented)

Guess you like

Origin www.cnblogs.com/elaine888/p/11927782.html