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.