def assert_element_in_page_source(s):
print type(s)
print s
#assert s in driver.page_source
command='assert_element_in_page_source(u"退出")'
print "type(command)",type(command)
eval(command)
执行脚本文件。报错如下错误,没找到原因,后续调查
D:\test>python test.py
ascii
type(command) <type 'str'>
<type 'unicode'>
Traceback (most recent call last):
File "test.py", line 85, in <module>
eval(command)
File "<string>", line 1, in <module>
File "test.py", line 81, in assert_element_in_page_source
print s
UnicodeEncodeError: 'gbk' codec can't encode character u'\x80' in position 1: illegal multibyte sequence