实战
来源:互联网 发布:网络炒作大概花费 编辑:程序博客网 时间:2024/04/28 03:32
如果想要在python程序中打印中文,默认情况下,你只会收到错误。在ex1.py中加入打印中文的代码,改成如下:
print "Hello Python!"print "Hello Again."print "I like typing this."print "This is fun."print "Yay!Printing."print "I'd much rather you 'not'."print 'I "said" do not touch this.'print "哈喽!"
再运行,就会发现报出如下错误。
File "ex1.py", line 8SyntaxError: Non-ASCII character '\xe5' in file ex1.py on line 8, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
那么实在需要打印中文,只需要在.py文件的首行加入编码格式说明(#– coding:utf-8 –)就可以。代码如下:
#-- coding:utf-8 --print "Hello Python!"print "Hello Again."print "I like typing this."print "This is fun."print "Yay!Printing."print "I'd much rather you 'not'."print 'I "said" do not touch this.'print "哈喽!"
阅读全文
0 0
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- 实战
- nil和NULL 的区别
- Java虚拟机运行时的数据区域
- mysql 5.6 主从复制配制
- ZOJ 1259(Rails)
- 在activity里面实现fragment管理
- 实战
- [BZOJ 4454]C Language Practice:GCD
- 排序之直接插入排序
- 乐驾项目博客-6
- Dagger2从基础到高级(二)
- UnicodeEncodeError: 'gbk' codec can't encode character '\u200b' in position 0: illegal multibyte seq
- hadoop集群默认配置和常用配置
- Android 使用 svg
- Poedu_Windows_进程