python3学习笔记(二)

来源:互联网 发布:sqlserver存储过程入门 编辑:程序博客网 时间:2024/05/11 19:06

一. base64 编码和解码任意的二进制字符串到文本字符串(主要用在HTTP EMAIL URL等 )
官方帮助文档原文:This module provides data encoding and decoding as specified in RFC 3548.
This standard defines the Base16, Base32, and Base64 algorithms for encoding and decoding arbitrary binary strings
into text strings that can be safely sent by email, used as parts of URLs, or included as part of an HTTP POST request

 

二. 3.1中marshal与pickle都能存取compile的Code对象
官方文档中不建议使用marshal:This is not a general “persistence” module.

 

三.array操作

 

四. py_compile编译单个py文件为pyc字节码文件
如果不指定保存的文件(compile第二参数),则将编译好的字节代码文件保存到py同一目录。
compileall 模块使用compileall.compile_dir()可以把一个目录树下的所有 Python 文件编译为字节代码.

 

五. linecache从源文件中读取代码(并缓存)

 

六. calendar查看日历

calendar.Calendar():查询日历的类(无格式化)
calendar.TextCalendar():取得文本日历字符串(可格式化)
calendar.HTMLCalendar():取得HTML日历字节的串(可格式化)

 

七. winreg操作注册表

 

八. keyword判断是否系统关键字

 

九. filecmp比较文件或者目录

 

十. cmd模块制作自定义命令行操作方式

cmd 模块为命令行接口( command-line interfaces , CLI )提供了一个简单的框架

只需要继承 Cmd 类, 定义 do 和 help 方法. 基类会自动地将这些方法转换为对应命令.

调用方式:

 

十一. bisect操作已排序列表

bisect二叉树计算如何插入已排序的列表,或者返回将插入值在已排序列表中的位置。这种方式比每次比较列表中值执行效率高。

原创粉丝点击