'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
Posted on 2018-11-24 13:18 翔云123456 阅读(365) 评论(0) 编辑 收藏 举报问题
rds_content = "{}, 执行了变更,sql语句:{}".format(ExecuteTime, sqls)
'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
解决方法:
由于字符串中包含中文字符,超出了acsii编码范围(128)。
只需要将字符串前面加上u字符,将其作为unicode进行处理即可。
rds_content = u"{}执行了变更,sql语句:{}".format(ExecuteTime, sqls)
参考
https://blog.csdn.net/lanyang123456/article/details/84436784
Just try, don't shy.