使用Python 3.5.3和pywinauto 0.6.2运行print_control_identifiers()时出错

时间:2017-04-09 04:10:45

标签: python-3.x pywinauto

运行print_control_identifiers()

时出现以下错误
`>>> app['TRACE\u2122 3D Plus'].print_control_identifiers()
Control Identifiers:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python35-32\lib\site-  packa
ges\pywinauto\application.py", line 636, in print_control_identifiers
print_identifiers([this_ctrl, ])
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python35-32\lib\site-  packa
ges\pywinauto\application.py", line 630, in print_identifiers
print(output)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python35-32  \lib\encodings\
cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2122' in   position
17: character maps to <undefined>
>>>`

我的配置是

`C:\Users\irgfff>pip freeze
comtypes==1.1.3
pypiwin32==219
pywinauto==0.6.2
six==1.10.0`

1 个答案:

答案 0 :(得分:0)

首先我认为这是一个pywinauto问题,但仍然不确定100%...... 尝试在脚本的开头插入以下注释(在第一行,这很重要):

# encoding: utf-16
# the rest of the script

无论如何,请告诉贵公司的软件工程师这个符号对可测试性和自动化不利。 :)