Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 2.7 操作错误:接近“&引用;:语法错误sqlite3错误_Python 2.7_Sqlite - Fatal编程技术网

Python 2.7 操作错误:接近“&引用;:语法错误sqlite3错误

Python 2.7 操作错误:接近“&引用;:语法错误sqlite3错误,python-2.7,sqlite,Python 2.7,Sqlite,我试图通过调用文件的函数在表中添加两个值。该文件包含以下代码: import sqlite3 con = sqlite3.Connection('rdb') cur = con.cursor() def insert(s): cur.execute("create table if not exists customerorder(no number primary key,menuitems varchar(40))") c=1 for i in s:

我试图通过调用文件的函数在表中添加两个值。该文件包含以下代码:

import sqlite3
con = sqlite3.Connection('rdb')
cur = con.cursor()
def insert(s):
    cur.execute("create table if not exists customerorder(no number primary 
    key,menuitems varchar(40))")
    c=1
    for i in s:
        print c
        print i
        cur.execute("insert into customerorder(?,?)",(int(c),i))
        c += 1 

def fetch():
    cur.execute("select * from customerorder")
    print cur.fetchall()
这是一份清单。 有s[0]=“简单书”和s[1]=“高级书”

你需要把它改成

insert into customerorder values(?,?)
表名后面的parens中的第一个列表是列列表,列名不能有
变量

insert into customerorder values(?,?)