登陆

报错 cursor() takes 1 positional argument but 2 were

def selectRecord(request):

    #cursor = conn.cursor()  

    cursor = conn.cursor(pymysql.cursors.DictCursor)

    cursor.execute('select * from book ', [])

    books = cursor.fetchall()

    conn.close()

    return HttpResponse(books)


这段代码用conn.cursor()  可以正常执行

用 cursor = conn.cursor(pymysql.cursors.DictCursor)

报错 cursor() takes 1 positional argument but 2 were given

这是为什么?


# Python入门
SamSam1648 天前4227 次浏览

全部回复(1)我要回复

暂无评论~
  • 取消回复
  • © 2021 Python学习网 苏ICP备2021003149号-1