我试图通过IronPython在Visual Studio中运行vba_extract.py。编译返回错误:
An unhandled exception of type 'Microsoft.Scripting.SyntaxErrorException' occurred in IronPython.dll
Additional information: Non-ASCII character '\xb7' in file ../../python/vba_extract.py ../../../tests/test.xlsm on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
我搜索了这个问题,并在vba_extract.py
的第2行添加了编码:
#!python
# -*- coding: utf-8 -*-
但它仍然不起作用。
此外,我尝试了以下两行,它们返回了相同的错误:
engine.ExecuteFile(@"../../python/irrelevant.py ../../../tests/test.xlsm");
engine.ExecuteFile(@"../../tests/test.xlsm");
所以我猜问题来自于test.xlsm
的编码。
有人可以帮忙吗?