文章内容

2025/10/29 1:30:26,作 者: 黄兵

UnicodeEncodeError: 'gbk' codec can't encode character '\u274c' in position 0: illegal multibyte sequence

最近在使用 ChatGPT 进行编码的时候,ChatGPT 帮我增加了调试代码:

try:
    print("⏳ [12] Call Swift to create a container...")
    create_container = init_swift.create_container(new_bucket_name)
    print("✅ [13] Swift 创建容器结果:", create_container)
except Exception as e:
    print("❌ [13] Swift Container creation exception:", e)
    return jsonify({'error': 'Failed to create bucket', 'details': str(e)}), 500

结果出现了:

UnicodeEncodeError: 'gbk' codec can't encode character '\u274c' in position 0: illegal multibyte sequence

这个错误主要是有些字符无法被编码,经过测试是由于调试代码中存在 emoji 导致出现编码错误。

结果方案:

直接删除调试中的 emoji,再进行调试,问题解决。

分享到:

发表评论

评论列表