文章目录
- 前言
- 一、报错信息*1st arg can’t be coerced to string*
- 二、报错信息*2nd arg can’t be coerced to string*
- 三、MeterSphere中通过vars.get(“xxx”)得到的值类型为unicode字符串
- 总结
前言
在使用MeterSphere编写Python脚本的过程中遇到了一系列编码的问题,现在通过这篇文章记录一些最近遇到的问题。
一、报错信息1st arg can’t be coerced to string
1st arg can't be coerced to string
错误指的是第一个参数无法被强制转换为字符串类型。
这种错误通常出现在使用 log.info() 或其他日志输出函数时。
比如,在使用log.info()想输出非字符串类型的值时,就会报上述错误。
# 使用 log.info 输出类型的错误示例
log.info(type(vars.get("str\_var")))