windows下python下,py脚本(test.py),os.system或subprocess.Popen调用dos命令失败,命令行下成功(windows->cmd.exe),脚本如下附加信息:
C:\Python27\python.exe E:/XtTradeClient/test.py
File "E:/XtTradeClient/test.py", line 5
SyntaxError: Non-ASCII character '\xba' in file E:/XtTradeClient/test.py on line 5,but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
Process finished with exit code 1
-------------------------------------------------------------------------------
# encoding='utf-8'
import os
if __name__ == "__main__":
info = '汉字'
cmd = 'echo ' + info
if 0 != os.system(cmd):
raise Exception('failed to call 'echo in command')
-------------------------------------------------------------------------------