我正在尝试从Groovy脚本执行Python脚本:)
以下是我如何执行命令:
def cmd = """guessit -j "$tmp" """
String output = cmd.execute()
其中$tmp
包含作为参数传递给groovy脚本的文件名。
如果有非ascii字符,我会得到Unicode错误(我在$tmp
中有俄语字母)
'ascii' codec can't encode characters in position 11-16: ordinal not in range(128)
编码是UTF-8,设置了-Dfile.encoding=UTF-8
Python错误日志
command: guessit -j "Агенты А.Н.К.Л. (The Man from U.N.C.L.E.).2015.WEB-DLRip.mp4"
Traceback (most recent call last):
File "D:\Soft\Python27\Scripts\guessit-script.py", line 9, in <module>
load_entry_point('guessit==2.0b3', 'console_scripts', 'guessit')()
File "build\bdist.win32\egg\guessit\__main__.py", line 150, in main
File "build\bdist.win32\egg\guessit\__main__.py", line 40, in guess_filename
UnicodeEncodeError: 'ascii' codec can't encode characters in position 11-16: ordinal not in range(128)
Python源代码在这里https://github.com/wackou/guessit/blob/2.x/guessit/main.py
如果我从cmd调用这个命令-没有错误。 操作系统是Windows7。非Unicode的语言是俄语
怎么了?你知道吗
已解决!
SET PYTHONIOENCODING=utf-8
设置stdin、stdout和stderr的python编码相关问题 更多 >
编程相关推荐