本文主要是介绍解决 SyntaxError: Non-ASCII character in file ‘E:\monkeyrunner\kyb_start.py‘, but no encoding declared,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题描述:
monkeyrunner执行python脚本报错:
C:\Users\Administrator>monkeyrunner E:\monkeyrunner\kyb_start.py
201210 14:24:36.820:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
201210 14:24:36.820:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]SyntaxError: Non-ASCII character in file 'E:\monkeyrunner\kyb_start.py', but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
原因分析:
脚本中含有中文字符,需在脚本开头注明编码格式
解决方法:
在脚本代码开头添加以下代码:
# -*- coding: UTF-8 -*-
重新执行脚本,即可运行成功
# -*- coding: UTF-8 -*-from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner import MonkeyDevice as md
这篇关于解决 SyntaxError: Non-ASCII character in file ‘E:\monkeyrunner\kyb_start.py‘, but no encoding declared的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!