python出错:AttributeError: 'int' object has no attribute 'encode'
部分代码:conn=pymysql.Connect(host='localhost',port=3306,user='root',password='na123123',...
部分代码:
conn=pymysql.Connect(
host = 'localhost',
port = 3306,
user = 'root',
password = 'na123123',
db = 't1',
charset = 'utf8'
)
with conn:
cur = conn.cursor()
cur.execute("SELECT * FROM t1.remark WHERE idnum < '%d'" % 6000000)
rows = cur.fetchall()
comment = []
for row in rows:
row = list(row)
comment.append(row[0])
def train_model(texts):
for li in texts:
comm = li.decode('utf-8')
运行到最后一行时出错,数据库中的数据并没有编码,希望提供修改后的代码
comm在之后一直要用到 展开
conn=pymysql.Connect(
host = 'localhost',
port = 3306,
user = 'root',
password = 'na123123',
db = 't1',
charset = 'utf8'
)
with conn:
cur = conn.cursor()
cur.execute("SELECT * FROM t1.remark WHERE idnum < '%d'" % 6000000)
rows = cur.fetchall()
comment = []
for row in rows:
row = list(row)
comment.append(row[0])
def train_model(texts):
for li in texts:
comm = li.decode('utf-8')
运行到最后一行时出错,数据库中的数据并没有编码,希望提供修改后的代码
comm在之后一直要用到 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询