.img='img.png'
.files={'img':('test.png',open(img,'rb'),'image/png')}
sdata={'username':username,'content':cont}
res=requests.post(url,data=sdata,files=files)
print res.text
ls=requests.get(url)
f=open("1.png",'wb')
f.write(f)
f.flush()
f.close()
#!/usr/bin/python
#coding=utf-8
import MySQLdb
self.conn = MySQLdb.connect(host='localhost',user='',passwd='',db='0')
cursor = self.conn.cursor()
cursor.execute( "INSERT INTO Dem_Picture (PicData) VALUES (%s)" , (MySQLdb.Binary(b)))
# self.conn.commit()
# 读取表内图片数据,并写入硬盘文件
cursor.execute( "SELECT PicData FROM Dem_Picture ORDER BY ID DESC limit 1" )
d = cursor.fetchone()[0]
cursor.close()
f = open( "C:\\22.jpg" , "wb" )
f.write(d)
f.close()
网友评论