Discuss / Python / raw_input()参数里不能写中文吗?

raw_input()参数里不能写中文吗?

我在命令行可以写中文,然后可以使用print输出

但是怎么我在编辑器里写了中文,比如 name = raw_input('请输入您的名字')后,我用print 打印报错呢?

c:\workspace>python hello.py
  File "hello.py", line 1
SyntaxError: Non-ASCII character '\xe8' in file hello.py on line 1, but no encod
ing declared; see http://www.python.org/peps/pep-0263.html for details

我右查看了一下,在编辑器里顶端加入了#--coding: utf-8--以后使用print u'汉字' 能正常的打印出来了

我想请问下比如

raw_input('参数')

这种带参数的,我参数如果要写中文怎么让他正常输出汉字提示呀?

WZDHXZHWBN

#3 Created at ... [Delete] [Delete and Lock User]

要加个u的

raw_input(u"参数")

  • 1

Reply