Skip to content

Commit 01d650c

Browse files
[投稿] 添加脚本: 照片统计 — by 今晚打老虎
1 parent a1beb9a commit 01d650c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import photos
2+
from collections import Counter
3+
import datetime
4+
5+
assets = photos.get_assets(media_type='photo', limit=0)
6+
print(f'共 {len(assets)} 张照片')
7+
8+
year_counter = Counter()
9+
for asset in assets:
10+
ts = asset.creation_date
11+
if ts:
12+
year = datetime.datetime.fromtimestamp(ts).year
13+
year_counter[year] += 1
14+
15+
print('\n按年份分布:')
16+
for year in sorted(year_counter):
17+
bar = '█' * (year_counter[year] // 10)
18+
print(f'{year}: {year_counter[year]:4d}{bar}')

0 commit comments

Comments
 (0)