スクリプトをインポートしてからrunnボタンを押すことで、ExcelでDataNitroを介してPythonスクリプトを実行しようとしていました。次のエラー メッセージが表示されました。
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)
代わりに、%paste 関数を使用してスクリプトを DataNitro の Python シェルにコピーペーストしたところ、機能しました。
スクリプトではなくシェルで機能したのはなぜですか? 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