2022年7月26日

Mov all jpg files ...

import os import shutil images = [f for f in os.listdir() if '.jpg' in f.lower()] os.mkdir('downloaded_images') for image in images: new_path = 'downloaded_images/' + image shutil.move(image, new_path) ref:python move file

2022年7月17日

[ ] and : :

Arryay 的'部份' 複製,可以用 ":"
[i:j:s]
  • i : from, default 0
  • j : to, default end
  • s : step, default 1, 也可以不寫
所以
A = B[:] 或是 B[::]
就是複製全部。
然後
A = B[::-1]
把B 倒著排