相关疑难解决方法(0)

使用带有多个扩展名的endswith

我正在尝试检测带有扩展名列表的文件.

ext = [".3g2", ".3gp", ".asf", ".asx", ".avi", ".flv", \
                        ".m2ts", ".mkv", ".mov", ".mp4", ".mpg", ".mpeg", \
                        ".rm", ".swf", ".vob", ".wmv"]
if file.endswith(ext): # how to use the list ?
   command 1
elif file.endswith(""): # it should be a folder
   command 2
elif file.endswith(".other"): # not a video, not a folder
   command 3
Run Code Online (Sandbox Code Playgroud)

python file list

28
推荐指数
2
解决办法
2万
查看次数

标签 统计

file ×1

list ×1

python ×1