我有这个错误AttributeError:'tuple'对象没有属性'encode',这是我的代码的一部分。你能帮我吗
cur = conn.cursor()
sql = "SELECT * FROM farm_registration \
WHERE barangay = %s", (e_barangay);
cur.execute(sql)
results = cur.rowcount
答案 0 :(得分:1)
此语句返回元组
sql = "SELECT * FROM farm_registration \
WHERE barangay = %s", (e_barangay);
你期待字符串,所以只需将上面的内容改为
sql = "SELECT * FROM farm_registration \
WHERE barangay = %s" % e_barangay;