Last active
April 13, 2016 10:16
-
-
Save MOOOWOOO/25a2c579e0f750db735f60b236fee775 to your computer and use it in GitHub Desktop.
pycurl 上传文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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