Joke Collection Website - Public benefit messages - Chinese garbled code in python programming.
Chinese garbled code in python programming.
This is because gbk coding is used in IDLE, which is an ascii extended character set.
& gt& gt& gt? Import? System copy command (short for system)
& gt& gt& gt? sys.getdefaultencoding()
Ascii' solution,
When executing in idle state.
Delete the U character before the string, and don't add the # code line.
Import sys first, then reload it (sys), and then use sys.setdefaultencoding("utf-8 "). Then you can print out a string with a u in front of it. (This is the search method. I experimented and found that there was no output here. . Restart IDLE to output, but it will become ascii)
Execute in a file
Declare the # encoding line at the beginning of the file, save the file as utf8 encoding, and add u at the beginning of the string.
- Related articles
- How does WeChat send group messages to the group?
- Speech at the Thanksgiving Appreciation Meeting of Insurance Customers
- How can I save my ex-wife's short message if I want to remarry?
- How to report spam messages pretending to be Unicom
- How to write a congratulatory message on New Year's Eve in the Year of the Tiger?
- Euler's good cat can't change color after booking a car.
- I only have text messages
- What about fraudulent text messages?
- Why didn't Shenzhen Shangliao Xiaoshengchu pass the preliminary examination in 2022 and didn't receive any information?
- How to set the SMS center number on Apple's mobile phone?