在运行带代码
的python 2.7脚本时with open(excelfile,'r') as openexcel:
for line in openexcel:
emp_firstname=line.split(',')[3]
emp_lastname=line.split(',')[2]
cursor.execute('SELECT id,Firstname,LastName FROM employee where
FirstName=? and LastName=?',emp_firstname,emp_lastname)
在emp_firstname=line.split(',')[3]
之后,emp_firstname值为Narélen,它会抛出错误,
cursor.execute('SELECT id,Firstname,LastName FROM employee where FirstName=? and LastName=?',emp_firstname,emp_lastname)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 3: ordinal not in range(128)
我也尝试了一些谷歌搜索,但仍然远离预期的结果。请建议一些方法来摆脱这个错误。