Python 中的字符编码
1、str类型可以理解为一个二进制block,或multibyte
2、multibyte_str.decode("<multibyte_encode_method>") -> unicode
3、unicode_str.encode("<multibyte_encode_method>") -> multibyte_str(binary block)
4、unicode_str 的操作参数也应为unicode,如:unicode_str.find("样本".decode("utf-8"))
5、代码里的u前缀会自动生成unicode字符串(它跟据源码首部的#coding:*** 段来决定应该怎样由multibyte生成unicode)
6、python 的print将输出binary block给console,colsole将用系统的multibyte_encode_method为显示这些binary block
REF
http://blog.sina.com.cn/s/blog_620c017e0100erh8.html
相关文档:
#将一些类型的文件压缩为7z.py
#for folder all file do 7z
import os
import sys
import distutils.file_util
def ImportOkFile():
if(os.path.isfile("D:\\Records\\将一些类型的文件压缩为7z_record.txt")==False):
f=open("D:\\Reco ......
小白和小菜是大学同学,这不快要毕业了,俩人一合计,找个培训班学点东西,武装一下头脑,顺便解决就业问题。
“你们要报哪个班啊?”接待他们的年轻小姐热心地问道。
“你们这里哪个班最好?”小白不假思索地说,“当然是报最好的班啦。”
“我们公司的培训项目都很好”小姐笑 ......
#coding=utf-8
from math import sqrt,cos,sin
import Image, ImageDraw
class SpireShape(object):
def __init__(self, draw):
self.draw = draw
self.line_width = 1
& ......
这两天在学习python语言,也学着写了个通讯簿,练习入门下!
功能包括以下:
1、增加一条记录
2、删除一条记录
3、修改一条记录
4、查询一条记录
5、显示整个通讯簿
6、帮助提示
7、版本显示
8、退出等
首先建立一个Person类,即Person.py文件,用来保存联系人记录:
class Person:
def __init__(self, nam ......
def retrive_emails(pop3_server, user_name, passwd, server_port):
#POP3
pop_client = poplib.POP3(pop3_server, port=server_port)
pop_client.user(user_name)
pop_client.pass_(passwd)
......