Bat文件在Windows上运行Python脚本

Bat file to run Python script on Windows

我已经在Windows7上安装了python 3.3,并创建了一个BAT文件来运行下面的python脚本:

1
2
3
4
5
6
7
8
set calc="C:/projects/libraries/closure-library/closure/bin/build/closurebuilder.py"
c:/Python33/python.exe %calc% ^
--root=C:/projects/libraries/closure-library/ ^
--root=C:/projects/mywebsite/assets/js/ ^
--input=C:/projects/mywebsite/assets/js/start.js ^
--output_mode=list ^
--output_file=C:/projects/mywebsite/assets/js/deps.js
pause

当我双击BAT文件时,会得到以下错误:

File"C:\Python33\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 6586: character maps to


其中一个Google关闭库python文件有问题(/closure/bin/build/source.py)修复方法是在打开文件时指定编码:

1
fileobj = open(path, encoding='utf-8')

有关如何解决此问题的详细信息,请访问https://code.google.com/p/closure-library/issues/detail?ID=603