🐚 作者: 阿伟 💂 个人主页: Flyme awei
🐋 希望大家多多支持😘一起进步呀!
💬 文章对你有帮助👉关注✨点赞👍收藏📂
如何解决Python出现UnicodeEncodeError错误?UnicodeEncodeError: 'gbk' codec can't encode character '\u2708' in position 0: illegal multibyte sequence
当PyCharm运行以下代码时
# -*- coding: utf-8 -*-
# @File : 复数.py
# @author: Flyme awei
# @email : 1071505897@qq.com
# @Time : 2022/8/3 17:13
# 机票购买页面
print('✈国内 \t\t♜国际.港澳台 \t↘发现低价')
print('----------------------------------------')
print('航班类型\t☉单程\t☉往返\t☉多程(含缺口程)')
print('出发城市:北京')
print('到达城市:长春')
print('出发日期:2022-3-8')
print('返回日期:yyyy-MM-dd')
print('----------------------------------------')
print('\t\t\t\t□带儿童\t□带婴儿')
print('\n\t\t\t\t\t[搜索]')
出现UnicodeEncodeError: 'gbk' codec can't encode character '\u2708' in position 0: illegal multibyte sequence
这样的错误 第一步,点击
File-->Settings
第二步 找到
Editor
下的 Code Style
中的File Encodings
,把Project Encoding:
的GBK
改为UTF-8
点击Apply
,然后OK
现在我们来重新运行代码试一下
可以看到代码可以正常运行
UnicodeEncodeError: 'gbk' codec can't encode character '\u2708' in position 0: illegal multibyte sequence
这样的错误就解决啦!