不知道怎么去解决这种问题?
懂VS和python的大神求指导 hi建议第一行做个编码声明# -*- coding: utf-8 -*-,然后再试试 thexiosi 发表于 2018-4-29 18:43
hi
建议第一行做个编码声明# -*- coding: utf-8 -*-,然后再试试
不行啊,还是没变化。。。 哈哈妹吖 发表于 2018-4-29 18:56
不行啊,还是没变化。。。
C:\Users\HZ\Desktop thexiosi 发表于 2018-4-29 18:43
hi
建议第一行做个编码声明# -*- coding: utf-8 -*-,然后再试试
加了之后,运行出现这个 File "E:\Python\程序练习\温度转化实例\温度转化实例\温度转化实例.py", line 1
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xc7 in position 0: invalid continuation byte
Press any key to continue . . . 哈哈妹吖 发表于 2018-4-29 19:07
加了之后,运行出现这个 File "E:\Python\程序练习\温度转化实例\温度转化实例\温度转化实例.py" ...
不好意思,我现在也不知道原因
建议把源码放上来(非截图),让大家帮你看看 # -*-coding:utf-8 -*-
import random
secret = random.randint(1,10)
temp = input("不妨猜一下小甲鱼现在心里想的数字是什么:")
guess = int(temp)
while guess != secret:
temp = input("哎呀,猜错了,请重新输入:")
guess = int(temp)
if guess == secret:
print("哎呀,你是小甲鱼肚子里的蛔虫么!")
print("哼,猜对了也没有奖励!")
else:
if guess > secret:
print("哎呀,大了大了")
else:
print("哎呀,小了小了")
print("游戏结束啦,不玩啦")
这个 打开.py,直接乱码。。
TempStr = input("��������Ҫת�����¶ȣ�")
if TempStr[-1]in["F","f"]:
C = (eval(TempStr)-32)/1.8
print("ת������¶���{:.2f}C".format(C))
elif TempStr[-1]in["C","c"]:
F = 1.8*eval(TempStr)+32
print("ת������¶���{:.2f}F".format(F))
else:
print("������ĸ�ʽ�������������룺") 感谢各位,问题已经解决了,是这样做的:
在 win下,就 vs 而言,文件开头添上这一行
# coding:cp936
============================
cp396 为中文在 win 下的编码方式
页:
[1]