DataNitro中的UnicodeError,excel

DataNitro中的UnicodeError,excel,unicode,ascii,datanitro,Unicode,Ascii,Datanitro,我试图在excel中通过DataNitro运行python脚本,方法是导入脚本,然后按runn按钮。我收到了这个错误信息: Traceback (most recent call last): File "27/scriptStarter.py",line 97,in <module> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 52: ordinal not in r

我试图在excel中通过DataNitro运行python脚本,方法是导入脚本,然后按runn按钮。我收到了这个错误信息:

Traceback (most recent call last):
  File "27/scriptStarter.py",line 97,in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 52:
 ordinal not in range(128)
回溯(最近一次呼叫最后一次):
文件“27/scriptStarter.py”,第97行,在
UnicodeEncodeError:“ascii”编解码器无法对位置52中的字符u'\xe5'进行编码:
序号不在范围内(128)
因此,我只是使用%paste函数将脚本复制粘贴到DataNitro的Python shell中,并且成功了

为什么它在shell中工作而不是在脚本中?在查找文件27/scriptstarter.py时,我甚至没有看到它。我真的不太了解这些东西,但是unicode和ascii之间的转换出错了吗

下面是我的小剧本,如果对你们有帮助的话

i=3
while i<4051:
    if 337 <=Cell(i,15).value<=23 and Cell(i,3).value>=1:
        Cell(i,19).value=1
    if 23 <=Cell(i,15).value<=68 and Cell(i,4).value>=1:
        Cell(i,19).value=1
    if 68 <=Cell(i,15).value<=113 and Cell(i,5).value>=1:
        Cell(i,19).value=1
    if 113 <=Cell(i,15).value<=158 and Cell(i,6).value>=1:
        Cell(i,19).value=1
    if 158 <=Cell(i,15).value<=203 and Cell(i,7).value>=1:
        Cell(i,19).value=1
    if 203 <=Cell(i,15).value<=248 and Cell(i,8).value>=1:
        Cell(i,19).value=1
    if 248 <=Cell(i,15).value<= 293 and Cell(i,9).value>=1:
        Cell(i,19).value=1
    if 293 <=Cell(i,15).value<=337 and Cell(i,10).value>=1:
        Cell(i,19).value=1
    i=i+1
i=3

而我您粘贴的脚本中似乎没有任何unicode,因此它应该可以正常运行。如果在导入时仍无法运行,请尝试将此行放在文件顶部:

# -*- coding: utf-8 -*-
这告诉Python源文件采用unicode编码,而不是ascii编码,应该可以解决这个问题