2015-09-23 43 views
-3

我试图用Python将图像插入到MySQL中。为什么我会得到预期的缩进块?

import mysql.connector 
import base64 

conn = mysql.connector.Connect(user="root",passwd="solomon",host="localhost",db="binarymanipulation",port="3306") 

cursor =conn.cursor; 
with open('/home/solomon/Downloads/javapic.jpeg', 'rb') as image: 

cursor.execute('INSERT INTO images(id,size,image) VALUES('PYTHON',245,image) ') 
conn.commit(); 
conn.close(); 

我在运行此代码时收到expected an indented block

我错过了什么?什么是正确的方式?

+2

@GreenChili,请不要修复OP的缩进。你只是删除了这个问题。 –

+0

@MorganThrapp是的,你是对的,回滚。 – CodeLikeBeaker

+2

oh dang现在我需要再次大写我的答案:P(只是在开玩笑) –

回答

2

你的第一个行不应该有一个空间,引领它

您以下with open("file.txt...线都应该缩进

但你也有断了的弦......在你的执行语句

相关问题