简体   繁体   English

为什么我会得到“预期一个缩进块”?

[英]Why am I getting `expected an indented block`?

I'm trying to insert an image into MySQL with Python.我正在尝试使用 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();

I'm getting expected an indented block while running this code.运行此代码时,我得到expected an indented block

What did I miss?我错过了什么? What is the right way?什么是正确的方法?

your first line should not have a space to lead it你的第一行不应该有空格来引导它

your lines following with open("file.txt... should all be indented你的行with open("file.txt...应该全部缩进

but you also have broken strings ... in your execute statements但你也有断线......在你的执行语句中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python:为什么我在elif(r &lt;= 9)上得到“预期的缩进块”: - Python: Why am I getting an “expected an indented block” on elif (r <= 9): 为什么我在这里得到“ IndentationError:预期缩进的块”? - Why am I getting “IndentationError: expected an indented block” here? 为什么我不应该得到缩进块? - Why am I getting expected an indented block when I shouldn't be? 为什么我一直收到“预期的缩进块”错误? - Why do I keep getting “expected an indented block” error? 我不断收到“IndentationError:期望一个缩进块” - I Keep Getting "IndentationError: expected an indented block" 我在 np.random.seed(2) 中收到“IndentationError: expected an indented block”。 如何解决这个问题? - I am getting “IndentationError: expected an indented block” in np.random.seed(2). How to fix this? 我在写一个方法,但是缩进块时出现错误 - I am writing a method but i get error expected an indented block 为什么我在 Python 文件上收到此错误“<stdin> ”,第 2 行 /n new_squares.append(squares[i]) /n ^ IndentationError: 期望缩进块?</stdin> - Why am I getting this error on Python File “<stdin>”, line 2 /n new_squares.append(squares[i]) /n ^ IndentationError: expected an indented block? 期望出现缩进的块错误 - Getting expected an indented block error IndentationError: 期望一个缩进块,但我不知道为什么 - IndentationError: expected an indented block but i dont know why
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM