📜  检查文件是否为txt python代码示例

📅  最后修改于: 2022-03-11 14:46:50.806000             🧑  作者: Mango

代码示例2
Assuming m is a string, you can use endswith:

if m.endswith('.mp3'):
...
elif m.endswith('.flac'):
...
To be case-insensitive, and to eliminate a potentially large else-if chain:

m.lower().endswith(('.png', '.jpg', '.jpeg'))