c.execute("INSERT INTO tb_info (id, summary) VALUES ('%s', '%s')" % (id ,summary))
经常会因为要插入文本summary中有特殊字符而导致失败,可以用以下方法,数据库会自动帮你转义:
c.execute("INSERT INTO tb_info (id, summary) VALUES (?, ?)" % (id ,summary))
博客指出在执行数据库插入语句“c.execute(\INSERT INTO tb_info (id, summary) VALUES ('%s', '%s')\ % (id,summary))”时,因插入文本summary含特殊字符常导致失败,给出解决办法,即使用“c.execute(\INSERT INTO tb_info (id, summary) VALUES (?, ?)\ % (id,summary))”让数据库自动转义。
c.execute("INSERT INTO tb_info (id, summary) VALUES ('%s', '%s')" % (id ,summary))
经常会因为要插入文本summary中有特殊字符而导致失败,可以用以下方法,数据库会自动帮你转义:
c.execute("INSERT INTO tb_info (id, summary) VALUES (?, ?)" % (id ,summary))

被折叠的 条评论
为什么被折叠?