From d159df3fc420b85ab33cabb53125582e83632432 Mon Sep 17 00:00:00 2001 From: liangweihao <734499798@qq.com> Date: Tue, 10 Feb 2026 18:32:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0blog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/content/posts/note/index.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/content/posts/note/index.md b/src/content/posts/note/index.md index 6fe371f..acfefa6 100644 --- a/src/content/posts/note/index.md +++ b/src/content/posts/note/index.md @@ -268,4 +268,16 @@ def main(): if __name__ == "__main__": main() ``` -# 待补充 \ No newline at end of file +# 达梦数据库使用python保存特殊字符时出现报错 +```shell +'gbk' codec can't encode character '\u2022' in position 687: illegal multibyte sequence +``` +现象:在数据库中查询是正常的,python查询、保存时会报错。 +原因:默认是gbk编码,无法解析特殊字符。 +解决方案: +需要指定编码格式 +```python +#local_code=1 表示执行客户端的本地编码是UTF-8,否则默认是GBK +dm_conn = dmPython.connect(user=dm_user, password=dm_password, server='localhost', port=5236, local_code=1) +``` +[参考链接](https://www.cnblogs.com/fangzpa/p/17285493.html)