Counter計數器
DEMO
from collections import Counter
s = "122333"
ct = Counter(s)
print(ct)
m = ct.most_common(2)
print(m)
# 動態統計
ct.update("1234")
print(ct)
print(ct.most_common(2))
DEMO
from collections import Counter
s = "122333"
ct = Counter(s)
print(ct)
m = ct.most_common(2)
print(m)
# 動態統計
ct.update("1234")
print(ct)
print(ct.most_common(2))
1. 構造器 方法和變量 super、self、this 4. python代碼實例 class Test(): # 類屬性 country = '中國' province = '陝西省' c
os常用的爲: os.walk os.listdir os.path模塊 假如test文件夾下有a、b兩個文件夾和一個ex.txt文本文檔。a文件夾下有a.txt和b.txt兩個文本文檔。