Author: Awei
Personal homepage: Flyme aweiI hope everyone can support and make progress together!
The article is helpful to you, follow, like and favorite
UnicodeEncodeError: 'gbk' codec can't encode character '\u2708' in position 0: illegal multibyte sequence
When PyCharm runs the following code
# -*- coding: utf-8 -*-# @File : plural.py# @author: Flyme awei # @email : [email protected]# @Time : 2022/8/3 17:13# Ticket purchase pageprint('Domestic\t\t*International.Hong Kong, Macao and Taiwan\tFind low prices')print('----------------------------------------')print('flight type\t*one-way\t*round-trip\t*Multiple passes (including notch passes)')print('Departure city: Beijing')print('Arrival city: Changchun')print('Departure date:2022-3-8')print('Return date:yyyy-MM-dd')print('----------------------------------------')print('\t\t\t\t with children\[email protected] a baby')print('\n\t\t\t\t\t[Search]')
An error like UnicodeEncodeError: 'gbk' codec can't encode character '\u2708' in position 0: illegal multibyte sequence
appears
The first step, click File-->Settings
The second step is to find Code Style under
in Editor
File Encodings
, change GBK
in Project Encoding:
to UTF-8
and click Apply
, then OK
Now let’s rerun the code and try it out
you can seeThe code works fineUnicodeEncodeError: 'gbk' codec can't encode character '\u2708' in position 0: illegal multibyte sequence
This error is solved!