The code is as follows: According to the Internet, adding #--coding:utf-8-- at the beginning will not work either
print("----------我爱鱼----------")
temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字:")
if temp == "8":
print("我曹,你是小甲鱼肚子里的蛔虫吗?!")
print("哼,猜中了也没有奖励!")
else:
print("猜错啦,小甲鱼现在心里想的是8!")
print("游戏结束,不玩啦^-^")
For your question, you need to add a line of coding format in the header, which is # -- coding: utf-8 -- (add it regardless of whether there is Chinese or not)
It seems like your format is not correct, try my code:
First of all, you need to add
#--coding:utf-8--
Secondly, the file itself needs to be stored in BOM-free UTF-8 encoding
Code indentation should use spaces instead of tabs
Looking at your code format, it should be Python 3 code, so it cannot be run using Python 2.x
I added a sentence at the beginning, and then executed it and found that it can be used, without changing a word in other places.
As shown in the picture: