在 Python 中读取 utf-8 文件
在 Python 中读取 utf-8 文件可以用 codecs 来实现:
import codecs file = codecs.open( "filename", "r", "utf-8" ) text = file.read()
最近在群里放了一个没头没脑小机器人来玩,说话的时候需要读一些 utf-8 格式的纯文本文件,用到了上边的代码。

在 Python 中读取 utf-8 文件可以用 codecs 来实现:
import codecs file = codecs.open( "filename", "r", "utf-8" ) text = file.read()
最近在群里放了一个没头没脑小机器人来玩,说话的时候需要读一些 utf-8 格式的纯文本文件,用到了上边的代码。

3 Comments
jogoo at October 2nd, 2008 at 7:38 pm :
python真是强大,学习!
敲敲门 at October 15th, 2008 at 11:16 pm :
弱弱的问一句~python是什么?=_=
Zhen Sun at November 14th, 2008 at 10:00 am :
Python