Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Python 3を使用してフォルダ内のすべてのpng形式の写真を削除するにはどうすればよいですか?
この 1 行のステートメントは、指定されたパス内の各ファイルを取得し、ファイル名が で終わる場合は削除し.pngます。
.png
import os os.remove(file) for file in os.listdir('path/to/directory') if file.endswith('.png')