且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python中文乱码解决

更新时间:2022-08-12 16:35:47

python 添加中文注释时出现运行失败。需要在顶部设置编码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# coding=UTF-8
'''
Created on 2013-8-28
@author: xmyj-0210
'''
number = 23
running = True
#while 开始
while running:
    guess = int(raw_input('Enter an integer:'))
         
    if guess == number:
        print 'Congratulations,you guessed it.'
        running = False
    elif guess < number:
        print 'No,it is a little higher than that'
    else:
        print 'No,it is a little lower than that'
#while 结束
print 'Done'

本文转自xuzw13 51CTO博客,原文链接:http://blog.51cto.com/xuzhiwei/1284494,如需转载请自行联系原作者