系统的内置模块
sys
hashlib
hmac
base64
time
datetime
sys模块:
|-- sys.argv() # 在Python脚本传参使用(很重要)
|-- sys.exit() # 系统退出
|-- sys.getdefaultencoding() # 获取系统默认编码
|-- getfilesystemencoding() # 获取文件编码
|-- getrecursionlimit() # 获取系统默认递归的最大层数
|-- setrecursionlimit(num) # 设置递归的最大层数
|-- getrefcount() # 获取对象的引用计数的数量
1.sys.argv() # 在Python脚本传参使用
结果为:
2.sys.exit() # 系统退出
3.sys.getdefaultencoding() # 获取系统默认编码
4.getrecursionlimit() # 获取系统默认递归的最大层数
setrecursionlimit(num) # 设置递归的最大层数
hashlib:
加密,散列加密(hash加密)
加密是否可逆:
|-- 可逆加密
根据加密和解密的秘钥是否是同一个
|-- 对称加密
DES
|-- 非对称加密
RSA
|-- 不可逆加密
hash是典型的不可逆加密
MD5、shal256
import hashlib
md5 = hashlib.md5(“需要加密的数据”.encode(“utf-8”))
1.MD5
time模块:
|-- asctime() # 获取系统当前时间
|-- ctime() # 获取系统当前时间
|-- time() # 获取当前的时间戳
|-- localtime() # 返回当前时间,以类似于元组的对象
t = time.localtime()
print(“当前时间是%s-%s-%s %s:%s:%s” %(t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec))
|-- time.strftime() # 将时间对象格式化成字符串
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|-- time.strptime() # 时间字符串转换为时间对象
time.strptime(‘2019/09/18 21:02:44’, “%Y/%m/%d %H:%M:%S”)
1.asctime() # 获取系统当前时间
2.ctime() # 获取系统当前时间
3.time() # 获取当前的时间戳
4.localtime() # 返回当前时间,以类似于元组的对象
5.time.strftime() # 将时间对象格式化成字符串
6.time.strptime() # 时间字符串转换为时间对象
datetime
|-- datetime.datetime.now() # 获取系统当前时间