-
Notifications
You must be signed in to change notification settings - Fork 0
python模块基础知识
GeHaha edited this page Nov 5, 2018
·
4 revisions
- a2b_* 函数接受只包含ASCII字符的Unicode字符串
- a2b_uu(string)
- b2a_uu(data, *,backtick= False)
- b2a_base64(data,newline = True)
- a2b_qp(data,header = False)
- b2a_qb(data, quotetabs=False, istext=True, header=False)
将二进制数据转换为一行ASCII字符的可引用打印编码。返回值是转换后的行。如果可选参数quotetabs存在且为真,那么所有制表符和空格都将被编码。如果可选参数istext存在且为true,则不会对换行进行编码,但会对尾随空格进行编码。如果可选参数标头存在且为真,空格将被编码为每个RFC 1522的下划线。如果可选参数标头存在且为false,换行符也会被编码;否则,换行可能损坏二进制数据
- a2b_hqx(string)
- rledecode_hqx(data)
按照binhex4标准,对数据执行rl -解压缩。该算法使用字节后的0x90作为重复指示器,后面是计数.计数0指定字节值0x90.例程返回已解压缩的数据,除非数据输入数据以孤立的重复指示器结束,在这种情况下会引发不完整的异常。
- crc32(data[,value])
print(binascii.crc32(b"hello world"))
#Or, in two pieces:
crc = binascii.crc32(b"hello")
crc = binascii.crc32(b" world", crc)
print('crc32 = {:#010x}'.format(crc))
- b2a_hex(data)/hexlify(data)
- a2b_hex(hexstr)/unhexlify(hexstr)
- base64
- binhex
- uu
- quopri
def__init__(self,[....):
def__del__(self,[....):
- dir() 返回对象的属性
- type() 获取对象的类型
class Programer(object): sex = 'male'
class Programer(object): def init(self,name,age,weight): self.name = name---可以公开访问 self._age = age---这个类的私有属性,但是也可以访问 self.__weight = weight----实现了部分私有属性,类可以,但是这个类生生成的对象不可以