在Robot Framework中,接收Python返回或引入外部文件中的变量,如果此变量的值为中文,在打印此变量的时候,会发现打印出来的结果是utf-8十六进制格式的字符串,而不是中文。需要通过解码的方式将其转换成utf-8编码内容,即可展示中文。
脚本如下:
${desc} Set Value ${data[0]}
log ${desc}
${desc_enc} Evaluate '${content}'.decode('utf-8')
log ${desc_enc}
运行结果:
INFO : ${desc} = Welcome to \xe6\x9d\xad\xe5\xb7\x9e
INFO : Welcome to \xe6\x9d\xad\xe5\xb7\x9e
INFO : ${desc} = Welcome to 杭州
INFO : Welcome to 杭州




