論python常見內建模組

2021-09-27 07:06:00 字數 1677 閱讀 1071

sys

hashlib

hmac

base64

time

datetime

1、sys模組:

sys.ar**() : 在python指令碼傳參使用(非常重要)

sys.exit() :系統退出

sys.getdefaultencoding() : 獲取系統預設編碼

getfilesystemencoding() : 獲取檔案編碼

getrecursionlimit() : 獲取系統預設遞迴的最大層數

setrecursionlimit(num) : 設定遞迴的最大層數

sys.setrecursionlimit(1000)

1000

getrefcount() : 獲取物件的引用計數的數量

2、hashlib:

加密,雜湊加密(hash加密)

加密是否可逆:

可逆加密

根據加密和解密的秘鑰是否是同乙個

對稱加密 des

非對稱加密 rsa

不可逆加密

hash是典型的不可逆加密

md5、shal256

import hashlib

md5 = hashlib.md5(「需要加密的資料」.encode(「utf-8」))

3、base64模組

b64encode() # 查詢資料,完成自學

b64decode()

4、time模組:

asctime() : 獲取系統當前時間

ctime() : 獲取系統當前時間

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() : 時間字串轉換為時間物件

論python常見內建模組

論python常見內建模組 1.系統的內建模組 syshashlib hmac sys模組 sys.ar 在python指令碼傳參使用 sys.exit 系統退出 sys.getdefaultencoding 獲取系統預設編碼 getfilesystemencoding 獲取檔案編碼 getrecu...

論python常見內建模組

sys.ar 在python指令碼傳參使用 sys.exit 系統退出 sys.getdefaultencoding 獲取系統預設編碼 getfilesystemencoding 獲取檔案編碼 getrecursionlimit 獲取系統預設遞迴的最大層數 setrecursionlimit num...

論Python常見的內建模組

sys hashlib hmac base64 time datetime sys.ar 在python指令碼傳參使用 sys.exit 系統退出 sys.getdefaultencoding 獲取系統預設編碼 getfilesystemencoding 獲取檔案編碼 getrecursionlim...