我正在尝试使用python脚本来更新我的数据库。当我尝试运行脚本时,输出在字段的实际值之前显示text:
或其他数据类型。有什么方法可以摆脱这个吗
for r in range(1, sheet.nrows):
EasementNumber = (unicode(sheet.cell(r, 0)))
Grantor = str(unicode(sheet.cell(r, 1)))
Book = str(unicode(sheet.cell(r,2)))
Page = str(unicode(sheet.cell(r,3)))
Day = str(unicode(sheet.cell(r,4)))
Month = str(unicode(sheet.cell(r,5)))
Year = str(unicode(sheet.cell(r,6)))
EasementType = str(sheet.cell(r,7))
Origin = str(unicode(sheet.cell(r,8)))
Descriptions = str(unicode(sheet.cell(r,9)))
ProjectName = str(unicode(sheet.cell(r,10)))
values = (EasementNumber, Grantor, Book, Page, Day, Month, Year, EasementType, Origin, Descriptions, ProjectName)
cursor.execute(query, values)
cursor.close()
cursor.commit()
您正在将单元格对象转换为字符串,而不是使用
cell
的value
您可以一次获取一行的所有值,而不是逐个读取单元格:
相关问题 更多 >
编程相关推荐