python 添加中文注释
2011-10-13 11:01
435 查看
在文件头上写入:
#coding=gbk
例如:
#coding=gbk
#mine,二进制相互转换
try:
from binascii import a2b_qp, b2a_qp
except ImportError:
print u'没有找到 binascii 函数库'
#二进制 ----> 可打印字符
file = open( 'd:\\tmp\\ua.ppt', 'rb' ) #读取二进制文件
data = file.read()
odata = b2a_qp( data, 0, 0 )
ofile = open( 'd:\\tmp\\o_ua.txt', 'w' ) #以文本文件方式写入
ofile.write( odata )
ofile.close()
file.close()
#可打印字符 ---> 二进制
file = open( 'd:\\tmp\\o_ua.txt', 'r' ) #读取文本文件
data = file.read()
odata = a2b_qp( data, 0 )
ofile = open( 'd:\\tmp\\o_ua.ppt', 'wb' ) #以二进制方式写入
ofile.write( odata )
ofile.close()
file.close()
#coding=gbk
例如:
#coding=gbk
#mine,二进制相互转换
try:
from binascii import a2b_qp, b2a_qp
except ImportError:
print u'没有找到 binascii 函数库'
#二进制 ----> 可打印字符
file = open( 'd:\\tmp\\ua.ppt', 'rb' ) #读取二进制文件
data = file.read()
odata = b2a_qp( data, 0, 0 )
ofile = open( 'd:\\tmp\\o_ua.txt', 'w' ) #以文本文件方式写入
ofile.write( odata )
ofile.close()
file.close()
#可打印字符 ---> 二进制
file = open( 'd:\\tmp\\o_ua.txt', 'r' ) #读取文本文件
data = file.read()
odata = a2b_qp( data, 0 )
ofile = open( 'd:\\tmp\\o_ua.ppt', 'wb' ) #以二进制方式写入
ofile.write( odata )
ofile.close()
file.close()
相关文章推荐
- 【python3问题解决】python3代码添加中文注释报错
- Python中添加中文注释
- Python 中添加中文注释以及中文输出解释器报错的解决办法
- python添加中文注释
- python 添加中文注释
- python 添加中文注释
- python中添加中文注释
- python使用MySQLdb,往库表内添加中文字段要做的修改
- python 中文注释 报错 SyntaxError: Non-ASCII character '\xe5'
- python运用中文注释时报错解决方法
- python单行、多行及中文注释
- 在python编辑器中输入中文注释的问题
- class.c 添加中文注释(3)
- Sublime Text编辑python程序中文注释报错
- SE38里行注释的添加取消与中文输入法冲突解决办法
- python文件支持中文注释
- Eclipse中添加对Python的中文支持
- python源代码中需要加入中文注释
- 树莓派python编程有中文注释就报错:SyntaxError: Non-ASCII character
- python 中文注释