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("游戏结束,不玩啦^-^")
欧阳克2017-06-22 11:54:04
# -*- coding: utf-8 -*-
__author__ = 'Administrator'
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)
女神的闺蜜爱上我2017-06-22 11:54:04
It seems like your format is not correct, try my code:
#coding: utf8
print("----------我爱鱼----------")
temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字:")
if temp == "8":
print("我曹,你是小甲鱼肚子里的蛔虫吗?!")
print("哼,猜中了也没有奖励!")
else:
print("猜错啦,小甲鱼现在心里想的是8!")
print("游戏结束,不玩啦^-^")
曾经蜡笔没有小新2017-06-22 11:54:04
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
伊谢尔伦2017-06-22 11:54:04
# -*- coding:gb2312 -*-
print("----------我爱鱼----------")
temp = input("不妨猜一下小甲鱼现在心里想的是哪个数字:")
if temp == "8":
print("我曹,你是小甲鱼肚子里的蛔虫吗?!")
print("哼,猜中了也没有奖励!")
else:
print("猜错啦,小甲鱼现在心里想的是8!")
print("游戏结束,不玩啦^-^")
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: