Skip to content

Instantly share code, notes, and snippets.

@MOOOWOOO
Last active April 13, 2016 10:16
Show Gist options
  • Save MOOOWOOO/25a2c579e0f750db735f60b236fee775 to your computer and use it in GitHub Desktop.
Save MOOOWOOO/25a2c579e0f750db735f60b236fee775 to your computer and use it in GitHub Desktop.
pycurl 上传文件
# -*- coding:utf-8 -*-
import pycurl
def Upload(file_name, url):
pc = pycurl.Curl()
pc.setopt(pycurl.URL, url) # URL
pc.setopt(pycurl.HTTPPOST,
[('logfile', (pc.FORM_FILE, file_name,))]) # {'logfile': xxx}
pc.perform()
response_code = pc.getinfo(pycurl.RESPONSE_CODE)
print response_code
pc.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment